Tuesday, July 21, 2009

Refactoring in ColdFusion Builder

First Let’s just discuss what is Refactoring the source code in general.

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 / tags, which are referring to this test() method are being considered for refactoring. Such URL references are possible to consider for refactoring only when the Server is registered with ColdFusion Builder and the URLs are very much valid and accessible, which otherwise is not possible.

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.



61 comments:

Govindaram said...

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

Jayesh Viradiya said...

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.

Anonymous said...

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?

Jayesh Viradiya said...

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.

Raghuram Reddy said...

in what way it is different from Dreamwever find/replace in the specified folder/file/opened files?

Jayesh Viradiya said...

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.

Anonymous said...

hi! i like your blog.. thanks for the sharing.. easy to download

michaelvk said...
This comment has been removed by the author.
Bob said...

I really appreciate the information you have provided in this blog especially about coldfusion. Thanks a lot! Very nice! health insurance california

Fabian Smith said...

This blog is awesome full of useful information that i was in dire need of.

Affiliate Management Solutions

Fabian Smith said...

This is really good advice. i also like this! thanks so much for this post!

Buy A Ready-Made Logo

Fabian Smith said...

This is definitely an amazing website for a beginner to get started. Timeline Facebook

Fabian Smith said...

Nice post having excellent contents.This is exactly what I’ve been looking for.Thank you very good. Applications for BlackBerry

Unknown said...
This comment has been removed by the author.
Unknown said...

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

Unknown said...
This comment has been removed by the author.
golf stayz said...

Your article is extremely impressive. I never considered that it was feasible to
accomplish something like that until after I looked over your post .

فروشگاه کتاب
فروش کتاب
خرید کتاب
خرید اینترنتی کتاب
فروش اینترنتی کتاب
خرید کتاب اینترنتی
فروشگاه اینترنتی کتاب
فروش کتاب اینترنتی

Unknown said...

It is in reality a nice and helpful piece of information. Local Advertising

Unknown said...

This is very interesting. thanks for that. we need more sites like this. Lux Style Awards

Unknown said...

I am really grateful to you for providing me with such useful information. Thanks a lot. Keep blogging. Hajj Packages
Economy Hajj Packages
Express Hajj Packages
Silver Hajj Packages
Executive Hajj Packages
Super Fast Hajj Packages
Hajj From INDIA Packages
Hajj e Badal Packages

Unknown said...

Nice post. Thank you for taking the time to publish this information very useful! I'm still waiting for some interesting thoughts from your side in your next post thanks! Wholesale Towels
Wholesale Cleaning Towels
Wholesale Hand Towels
Wholesale Microfiber Towels
Wholesale Salon Towels
Wholesale Shop Towels
Wholesale Vending Towels

Unknown said...
This comment has been removed by the author.
Unknown said...

Thanks for sharing your website.This blogs are very informative. I really say thanks to you. Used Police Cars

Unknown said...

It is so lucky to read your blog,it is full of useful message.I wish we both can do better in the future.It great honor if you can visit our website,and give us some suggestion. Dawn Travels
Hajj Packages
Umrah Packages

Unknown said...

Charge card help considerably boost additional improvements is normally mostly high-priced, though while even though this specific, any individual check-up charges associated with low-cost charges mutually and also great home home finance loan obligations, it could maybe fully reported indoor a lot more cost-effective with regards to the help considerably boost additional improvements considerably boost. It is best to fully need to obtain complicated that you can devote $793 in hardly ever aspect mutually and also charges that features real estate personalized cash loan indoor normal normal classic normal classic traditional bank.check cashing costa mesa

Anonymous said...

Your usually regular installments is sometimes found distinctive with eight throughout this technique on twelve bi-week by week parts, or even still, at intervals the event that your equity credit line depends on your individual Sociable Stability acquire, thus we have got a slant to appear at out for have associate title loan inclination to might began your installments to urge got from 3 to four customary month to month prices. Dependably centered on parts manual for prove a reduced check whole that's the larger match your funds.

Anonymous said...

The Office of Reasonable Trading spent a year looking at the market and found widespread evidence of irresponsible loaning and breaches of the law. It said borrowers were suffering "misery and hardship" as a result of fundamental problems with the way lenders auto title loans chicago operated, putting speed ahead of everything else.

Anonymous said...

“For those who struggle with their repayments, we are ensuring that someone credit ranking £100 will never repay more than £200 in any circumstance."“There have been many strong and aggressive views to take into consideration, but I am confident we payday loans have found the right balance."

marko said...

In realtà, sfide fisiche sono il secondo motivo più comune che gli anziani smettere di fare sesso. Le malattie cardiache, diabete e cancro può influenzare la capacità di una persona di funzionare sessualmente. erezioni solide a 60 anni

marko said...

La tua pagina web deve aspetto professionale ed essere chiari su ciò che si sta cercando di raggiungere. Se possibile lasciare la bozza finale per un giorno o due, poi ri-leggere. E 'sorprendente come spesso si noterà errori madornali, o vedere un modo molto migliore di dire qualcosa. come fare il cv in inglese gratuito

Justin said...

Va da sé, che si dovrebbe avere una buona padronanza delle lingue nella tua combinazione linguistica, è inoltre necessario avere familiarità con la cultura e costumi del paese. L'unico modo per farlo è circondandosi con la lingua, i.e: da soggiorno / studio nel paese in cui si parla la lingua. scrivere un curriculum vitae inglese per il canada

Justin said...

Ho chiesto perché, e lei ha detto guardando i 2005 e 2006 scansioni, 2008 scansione era migliorata, non riusciva a crederci, e ha detto di solito quando ci si trova nella gamma osteoporosi, non vieni fuori "(10). Quel medico era in realtà dicendo che sapeva che il trattamento accettato di supplementazione di calcio alto non funziona, ma usano comunque. difficolta di erezione a 60 anni

Cheap Umrah US said...

Very helpful article thanks for sharing!!!



economy umrah package

Oracle Fusion said...

That is a good tip especially to those new to the blogs here but very accurate information. Very nice blog post!! Thanks for the posting that is a really neatly written blog.
Oracle Fusion EBS Training

writing tips said...

Your article has provoked a ton of positive hobby. I can see why since you have made such a decent showing of making it intriguing
Coursework writing service

Megan Ryan said...

Refactoring code is something new for me and I'm not sure that I can use it in the future. But I'm sure that job search tips will be useful for everyone at least once.

Ciana Langham said...

Hello! I want to share with you one awesome website that helped me with writing papers. It's called essaywriters net I have some problems with writing and wasn't sure that I can do it alone.

Mike Collins said...
This comment has been removed by the author.
Mike Collins said...

Thanks for the great article. It's easy to understand and might be useful for beginner, especially for those who start coding. For me, it's complicated a bit so It would be great someone describes it in how to essays

seocom said...


خدمة شراء الأثاث المستعمل
يحتار الكثير من العملاء عند استبدا أثاثهم القديم بأثاث أخر جديد إلى اين يذهبون أو يفعلون بأثاثهم المستعمل ولكن بعد الآن لا تقلق في حيال ذلك فحن من خلالنا قد قدما لكم محلات خاصة بعملية شراء اثاث مستعمل بالمدينة المنورة التي تعمل على شراء الأثاث المستعمل وإعادة تنظيفه وتلميعه وعرضه في معارض ومحلات الشركة التي تساعد فئة أخرى من العملاء في الحصول على أثات مستعمل ولكنه في نفس الوقت جديد لا يعيبه شيء، ونقدم إليكم أثاث مستعمل بالمدينة المنورة بأرخص الأسعار والتي تتناسب مع جميع عملاء الشركة الكرام.
كما أن الشركة تقدم لهم أفضل العروض والخصومات التي تروق لكثير من العملاء، فمن الآن وصاعد يمكنكم بيع وشراء الأثاث المستعمل بأفضل الأسعار التي تتناسب مع العملاء ومع أسواق المدينة المنورة.

melodyanderson said...

We are technical support team for accounting software.if anyone has any kind of problem with any accounting software like quickbooks,quicken,sage,turbotax.,please dial our support number for instant help.
quickbooks support customer service
sage phone number
quicken tech support number
turbotax customer support

Unknown said...

Thanks this helped me a ton!

Hajj Packages
VIP Hajj Packages
Umrah Packages
Hajj Packages 2020
Economy Hajj Package

All Customer Service Number said...

You can install Microsoft office and using its features easily. Here you can know the activation process of Microsoft office in your computer by visiting "How to activate Microsoft Office".

malina smith said...

Thanks for the advice. The blog is really useful and informative. I will definitely use the tips. thank you for sharing the post.If you are looking for the best business antivirus , mcafee antivirus at affordable prices in unitedstate, then you may visit this website. Bizpoke provides the most reliable business antivirus
visit@-
mcafee.com/activate |
mcafee.com/activate |
norton.com/setup |
office.com/setup

anthony said...

You can make use of Gmail Password Recovery Phone Number and retrieve your account. First, create a Gmail account and then proceed.

anthony said...

Tap on www.epson.com/connect and then specify your Printer Model Number along with the OS version you are operating on.

anthony said...


Visit epson.com/connect and you can find solutions to your printer related queries. Access [url=https://epsonqueries.blogspot.com/2019/11/epson-printer-issues.html] www.epson.com/connect [/url] and you can get rid of any problem impeding your printer's functions.

smithzack792 said...

Thank you so much for sharing these amazing tips. I must say you are an incredible writer, I love the way that you describe the things.I’m also interested in writing and programming. You can read my blog with a click on the button below.

office.com/setup | www.norton.com/setup | office.com/setup

Bitdefender Login said...

This is a very helpful Blog articale thanks for sharing with us I like this Article.Thnak You so much.
Mcafee.com/mis/retailcard | mcafee.com/activate

Deam jones said...

Make sure to only purchase the right product that matches your security obligations. As Norton offers you a trial version of every product online without implying any charges, you can easily get to know their performances before paying for the subscription plan.

norton.com/setup

norton.com/setup

Norton Setup said...


Office setup website is one of the best websites. You might have though of many

software platforms that give you access to the new and amazing tools for productivity at

home and office.
www.office.com/setup

OutlookPasswordReset said...

HP printer support online is an independent service provider for computers and peripherals. Hp Printer Support online has no affiliation with any third-party brand unless otherwise specified. On-site services are provided by third-party technicians on behalf of Hp Printer Support online.

Read more:: HP Support Assistant

OutlookPasswordReset said...


HP assistant download is a HP application that can assist you with upgrading your PC execution and resolve issues with mechanized updates, investigating instruments, online specialized substance, and a few help alternatives it Resolve numerous basic issues utilizing HP Support Assistant's troubleshooters and computerized fixes.

Read more: Hp printers troubleshooting

malina smith said...

McAfee Management for Optimized Virtual Environments AntiVirus McAfee MOVE AntiVirus four is handy now. This look of our propelled affirmation for digital machines is revolved round supporting clients acquire the going with outcomes for their personal cloud associations: visit@:- mcafee.com/activate

Aiden Jangra said...

Here you can get complete guide in several ways. This article covers all those steps and methods to connect your HP printer to wifi Network. If you do not have access to the wi-fi but need an immediate printout, then the WiFi direct comes to the rescue.

Roku-comlink said...

Roku is a streaming player which provides enormous entertainment features. It comprises a series of devices which fetches the data from the Internet and output the same via TV.To use Roku with ease, you just need to know Roku.com/link code enter process. Using the Roku remote will help you to scroll up and down the language list and finalize the preferred language by pressing the OK button.

Albert Harvey said...

You have given a detailed information, thank you so much for sharing this piece of writing here. I hope this is helpful for many of them who read your blog post. I have bookmarked this page for reading upcoming blog posts.Good job, keep it up!
https://www.muslimsholytravel.co.uk/

John Shaw said...

Vpn for mac
android tv vpn
apple tv vpn
vpn download for windows 7
affordable vpn
best vpn for mac
which is the best vpn for iphone

Fubo.tv/Activate said...

Watching TV is one of the biggest pass time for the entertenment. It is now known that the average American spends over 14% of his time watching TV if not more. The older the age group, the more TV they tend to watch with the teenage watching the least TV in any given year. This means that watching FuboTv is one of the biggest things in American and even world over. It therefore makes sense to ensure you have the best way to watch FuboTv and watch the most channels. fubo.tv/Connect

Fubotv Activate said...
This comment has been removed by the author.
Ambika Divinity Haridwar said...

The Shubham Group is delighted to offer Apartments for sale in Haridwar. ADH is offering flats in haridwar The completed project of Ambika Divinity Haridwar commenced in 2015 at the most fancied location to provide you home in the Gangotri Shanti Kunj, Motichur, Motichur Range, Haridwar . A place which is blessed with the surroundings of temples like Vasino Devi Mandir, Bharat Mata Mandir, Chandi Devi Mata Mandir, Shanti Kunj and much more. Reach us if you are looking for the best residential property in haridwar.