What is Refactoring ?
Refactoring code in a programs means, one cleans up the code to improve the understandability, maintainability of the source code by changing source code’s internal structure or design, but keeps the overall result of the program same.
So next question one would is “How do I Refactor my program’s source code ?”
First thing, it must not be done manually by one, as it’s more prone to human errors. Refactoring has to be an automated process and it’s a feature of and provided by the most of the IDE.
ColdFusion Builder is the new IDE provided by Adobe for Rapid development of ColdFusion applications. ColdFusion builder allows user to Refactor their application source code.
So one may argue…What’s the big deal with ColdFusion Bulider? most of the IDEs provide refactoring…
The big deal here is that it’s very challenging task for a non-typed language to provide Refactoring feature. ColdFusion being a loosely typed language, it’s not that straight forward to implement Refactoring for ColdFusion Builder, but still an attempt has been made to provide this feature in ColdFusion Builder to make life easier for CF developers.
What should I refactor to improve the understandability or maintainability of my source code?
During the application development cycle, one may hurry to complete the application due to various reasons and hence may end up using the variable names, function names, filenames and many other source code constructs such that it becomes difficult to understand for other developer, making maintainability and understandability of the application difficult. In order to avoid such situation, developer should take corrective actions to Refactor the above mentioned code constructs for making it easier to comprehend for other developers.
What sub-features does ColdFusion Builder offer for Refactoring?
ColdFusion Builder provides the following sub-features in Refactoring.
CFC UDF Refactor
In the following component, let’s say…one want to rename test() function to test123(), so it means that all the valid instances of the test() function through out the application should get refactored, including the references in the same component but other functions referring it.
<cfcomponent namespace="Refactor.abc" extends="def.b" >
<cffunction name="test" access="remote">
<cfreturn 1>
</cffunction>
<!---Test 2 Method --->
<cffunction name="test2" access="remote">
<cfreturn test()>
</cffunction>
<!----Test Method 3 from def\b.cfc---->
<cffunction name="test3" access="remote">
<cfreturn foo1()>
</cffunction>
</cfcomponent>
So what should one do to achieve it? Just left click on the function name, and then Right click to open the Menu, as shown in the following screenshot.

Click on the Refactor->Rename menu item and it will open up a Input dialog as following,
Now, provide the “New Name” for the test method and once you do that Disabled Preview button is enabled. Notice that we are enforcing user to preview the changes being done by ColdFusion Builder. Reason being at certain places, CF can not determine if the instance has to be considered for refactoring or not and so in such cases, it’s upto user to decide if the unsure instances (unchecked) shown in the preview, has to be considered or not. If required user should check it before preceding by pressing “OK” button.
Notice that even the URLs in
Note: User can Undo the Refactored changes by pressing Cntrl+Z from keyboard.
So we have seen how to refactor an UDF in CFC. Similar way, we can also perform the following operations.
- Refactor CFM UDF
- Refactor CFC UDF
- Refactor Funcion Local scope variables
- Refactor Function Argument Names
- Refactor the CFC Name
- Refactor CFM Name
- Refactor Custom Tags
- Refactor CFQuery Names
- Refactor Scoped Varaible names like This/Application/session etc.. variables.
- Refactor UnScoped Global variables in a CFM/CFC.
- Refactor Variables in Included and Includee file.
- Refactor ORM CFC which should also get reflected in ORM Entity Methods.
- Method Refactoring through – “Application Varaible Mappings” in CF Builder
Note: To refactor the CFM/CFC/CustomTags, Explore the Template thorough Project Navigator, Right Click on the Template and select Refactor->Rename menuitem, as shown in the following screenshot.

Note: File/Template Refactoring is allowed only for, CFM/CFC files. TXT files or any other types of files can not be refactored.
Method Refactoring using "Application Variable Mappings"
Assume a scenario where an Application variable is defined for a CFC Object as following.
<cfset Application.appVar = createObject("component","abc.AppCFM.a")>
And now, the CFC function called Method() is invoked as following in some other template
<cfset Application.appVar.Method()>
In such a case, While Refactoring the Method() function, If a Varaible mapping is created for the application variable, then the above invokation usage will be considered for Refactoring, otherwise it will be ignored.
To Create Application Variable mappings.... Right Click on the Project >Properties window>ColdFusion Variables Mappings>Click on New button>enter Variable name as "Application.appVar" and Mapped To as "abc.AppCFM.a", Click OK button.
References Search
Not that always one needs to refactor the Code, But there are times, when one only wants to see/find the references of the Methods/Varaibels/CF templates etc…
In such a case, one can use the References option in the Right Click Menu, as shown in the following screenshot.

Similar option is also available for Template search from Project navigator view.
Reference search results will be shown in the Search panel as shown below.



30 comments:
Look like Coldfusion Builder is interpreting CFC name relative from the Project's root folder.
But in productive sites CFCs spreads across multiple folders like:
/.../cfc1folder/f1/cfc1.cfc
/./cfc2folder/f2/f3/cfc2.cfc
These CFCs will be consumed in some other CFM/CFC with relative name like:
f1.cfc1
f2.f3.cfc2
And ColdFusion server understands CFC's full name from the paths provide under 'Custom Tag Paths' section of CF Admin.
How Coldfusion Builder helps in these scenario either during Refactoring or Referencing or Code Assit?
Is there any option to let Coldfusion Builder know the list of 'Custom Tag Paths'?
-Govind
CFC path resolution mechanisim is in place in ColdFusion Builder for the scenarios mentioned by you. In CF Builder a project is associated with CF Server, and hence it's easy to find out custom tags, CF mappings and also resolve CFC paths from webroot or relative to Project folder which is also under the workspace created under wwwroot. So Content Assist or Refactoring will know how to resolve the CFC references.
Given that CF is a such a loosely typed language what is your general strategy on tackling refactoring?
I can easily come up with a number of scenarios for which it's not possible to know the refactoring using static analysis!
How about this simple example:
Suppose I have component A and component B both with UDFs m. How would I be able to refactor the method m for component A? What does the editor do to help you out in this situation where it is ambiguous?
[cfset x = createObject("component", "A") /]
[cfif expressionNotKnowUsingStaticAnalysis]
[cfset x = createObject("component", "B") /]
[/cfif]
#x.m()#
And since this scenario can play out in so many ways, how effective do you expect refactoring to be on real codebases?
Hi Bob,
Regarding 'Number of Scenarios', while developing this feature, even we had this thing in mind and have tried to cover most scenarios.
Regarding your UDF ambiguity example, this is very much a possibility, as there will be times when certain thigns will be clear only on Runtime and not compile time. We display such ambiguous cases in the preview screen but those cases will be UNCHECKED, leaving upto user to decide if to refactor or not. And also, as I have explained in my post, we force preview on user to review, before pressing the OK button. So moral of the story is, we leave upto user to decide on such runtime ambiguous cases.
in what way it is different from Dreamwever find/replace in the specified folder/file/opened files?
Find/replace is just the content based dumb keyword matching searching on files/folders...here user has to be on his toes while performing this operation as otherwise it will replace unnecessary instances of the matching keywords also, resulting in broken source code. Refactoring is an intelligent technique in IDE to find/replace the right insntaces/references and it just doesnt go by the matching names.
hi! i like your blog.. thanks for the sharing.. easy to download
Hi,
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading.
Nice blog. I will keep visiting this blog very often.
-
Delphi development
I really appreciate the information you have provided in this blog especially about coldfusion. Thanks a lot! Very nice! health insurance california
This blog is awesome full of useful information that i was in dire need of.
Affiliate Management Solutions
This is really good advice. i also like this! thanks so much for this post!
Buy A Ready-Made Logo
Your article is extremely impressive. I never considered that it was feasible to
accomplish something like that until after I looked over your post .
Gold Coast golf
Gold Coast golf holidays
Sunshine Coast golf
Sunshine Coast golf holidays
Group golf holidays
Australian golfing holidays
Discount golf
Golf trips
I just wanted to leave a comment to say that I enjoy your blog. Looking at the number of comments, I see others feel the same way! Congratulations on a very popular blog.
Boat Finance
This is definitely an amazing website for a beginner to get started. Timeline Facebook
Nice post having excellent contents.This is exactly what I’ve been looking for.Thank you very good. Applications for BlackBerry
ColdFusion is still in market I don't think so? How many companies are using ColdFusion as a software platform? Now, Developers are using PHP or JavaScript for programming and very of them know ColdFusion.
Regards,
Susan Gray
Social Media App
Thank you for the great article I did enjoyed reading it, I will be sure to
bookmark your blog and definitely will come back from again.
I want to encourage that you continue your great job, have a good day
north london business oppotunities
london business group
Nice article you got here. It would be great to read more about this theme. The only thing it would also be great to see on this blog is some pictures of any gizmos.
feather flag
flag banner
custom flag banners
Thank you for the great article I did enjoyed reading it, I will be sure to
bookmark your blog and definitely will come back from again.
I want to encourage that you continue your great job, have a good day
north london business oppotunities
london business group
london nwtworking groups
london business networking
It is great to observe somebody put enough craze towards a matter. I'm thankful that I stumbled upon this process. I am lucky I used the time to read on past the 1st paragraph. You have got a whole lot to say, very much to offer. I really hope guys understand this and look into your page.
safety deposit box
bank safety deposit boxes
mailbox post
residential mailboxes
gold bar for sale
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading what you all have to say
real estate law
how to buy a house
first time home buyer programs
Your article is extremely impressive. I never considered that it was feasible to
accomplish something like that until after I looked over your post .
فروشگاه کتاب
فروش کتاب
خرید کتاب
خرید اینترنتی کتاب
فروش اینترنتی کتاب
خرید کتاب اینترنتی
فروشگاه اینترنتی کتاب
فروش کتاب اینترنتی
Your article is extremely impressive. I never considered that it was feasible to
accomplish something like that until after I looked over your post .
فروشگاه کتاب
فروش کتاب
خرید کتاب
خرید اینترنتی کتاب
فروش اینترنتی کتاب
خرید کتاب اینترنتی
فروشگاه اینترنتی کتاب
فروش کتاب اینترنتی
Nice post. It would be great to read more about this theme .
safe investment
forex investment
managed accounts
forex managed account
managed account
forex managed
pamm account
instaforex
It is in reality a nice and helpful piece of information. Local Advertising
This is very interesting. thanks for that. we need more sites like this. Lux Style Awards
I just wanted to leave a comment to say that I enjoy your blog. Looking at the number of comments, I see others feel the same way! Congratulations on a very popular blog.
Metropolitan Safe Deposit Boxes Limited or Bank Safe Deposit Boxes limited (‘Metropolitan’) was originally formed in 1983 to construct and operate the Belgravia safety deposit box , Metropolitan’s safety deposit box facilities are strategically placed in the inner central area of Metropolitan London. The Company is the largest independent provider of Safe Deposit Boxes
Bank Safe Deposit Boxes Safe Deposit UK Bank Safe Custody Safety Deposit Boxes
Safe Deposit Facilities Safe Heaven this service in the United Kingdom. The two vaults provide thousands of boxes in 16 different sizes ranging from one-foot square and two-inch high boxes up to walk-in secure storage areas. The locations of the vaults are in Knightsbridge and St John’s Wood.
Post a Comment