ColdFusion Builder 2: Improving the Coding Experience
ColdFusion Builder 2: Improving the Coding Experience
Join the DZone community and get the full member experience.Join For Free
Distribute microservices between the private and public clusters, yet maintain bi-directional connectivity. Content provided by IBM Developer.
As a user of the first release of Adobe ColdFusion Builder, an Eclipse-based IDE for doing ColdFusion development, I was quick to download the beta version of Builder 2 when it was released in early March on the Adobe Labs website. After having used it on a daily basis for almost two months, I can say that while the new features in Builder 2 are more evolutionary than revolutionary, they significantly enhance the usefulness of the IDE.
The purpose of any decent IDE is to streamline the process of writing the actual code, so it was no surprise that most of the improvements in Builder 2 are found in the code editor. Chief amongst those improvements is a more intelligent Code Assist feature. While the first version of Builder did provide some prompts with function and attribute suggestions as I was typing out my code, I tended to ignore it because the guidance it provided was somewhat limited and I felt like it got in my way. The Code Assist in Builder 2 gives me more control over the offered suggestions and can list the appropriate additional attributes for a given tag or function based on what I've coded so far.
Here's an example: the <cffile> tag in ColdFusion Markup Language (CFML) can be used to perform different kinds of actions on files, depending on the value of the "action" attribute in the tag. In Builder 2, if I type "<cffile " in the editor, I'll be shown a list of the possible attributes with that tag. The "action" attribute for <cffile> is always required, so it's listed at the top with a checkmark next to it:
Selecting "action" from the list will then cause Builder to display a list of the possible values of that attribute:
If I choose "write" as the "action" value, Builder will automatically add the two additional required attributes needed to perform a file write operation:
But if I were to choose a different value for "action", such as "upload", Builder will just add the one additional required attribute for an upload operation:
I can also pull up a list of optional attributes at any time by hitting Control-Spacebar on my keyboard.
If I'm writing a function, codeAssist can also prompt me for the arguments need by the function. So if I was writing a call to the ListFind function in cfscript (one can write ColdFusion code in either tag-based CFML or script style cfscript depending on one's preference), I could type in the function name then hit Control-Spacebar on my keyboard and receive a prompt to specify what variable I want to use for the first argument (the "list" argument, in this case):
Notice that the list of possible argument values includes the two string variables defined in my code, as well as the standard variable scopes used in ColdFusion ("application", "client", etc.), but leaves out the "myInteger" variable. That's because Builder evaluates the myInteger variable and knows that it contains an integer value and therefore would be an invalid choice for the first argument of ListFind.
Another feature in Builder 2 that I find helps me write my code are the brand-new code formatting preferences. I can change how Builder formats my code as I'm typing by opening the global Preferences window in Eclipse, then clicking on ColdFusion -> Profiles -> Editor -> Formatter to open the Formatter window:
The Formatter gives me a lot of options for customizing how my code will look. A few examples:
- I can dictate whether CFML tags added by Code Assist are all lowercase or uppercase, and which tags receive a closing slash automatically.
- I can specify which tags trigger an automatic indent when I move to the next line, and how big each indent should be.
- I can set when and where whitespace and blank lines are added.
- If I'm writing in cfscript, I can indicate whether or not I want the starting brace of a code block to appear at the end of the current line or the beginning of the next line (a common debate amongst programmers).
Having Builder format my code for me in the style that I prefer is a big help: it saves a lot of keystrokes and keeps my code looking consistent. And if for some reason my code ends up being formatted incorrectly (as can happen if I paste in a block of code from elsewhere), I can select said code, right-click on it, and choose "Format" from the context menu, and Builder will fix the formatting of the code.
Another new editor feature I like in Builder 2 is the ability to navigate, select, and hide code blocks. A lot of the code I write (and this is true for more programmers) is organized in logical blocks: conditional statements, loops, functions, etc. In Builder 2, if my cursor is within such a block and at the beginning or end of the current line of code, hitting Control-Alt-M (Windows) or Command-Alt-M (Macintosh) will select/highlight the end tag of the containing code block, and hitting that key combo again will select the beginning tag:
Using the same cursor placement but hitting Control-Alt-B (Windows) or Command-Alt-B (Macintosh) will select the entire code block:
Both of those keyboard shortcuts come in handy when I'm dealing with nested code blocks that span more than one screen and I can't tell which code block I'm looking at. On the other hand, if I'm working in a large file where the code blocks I'm interested in are separated by a hundred or so lines of code, I can reduce the amount of scrolling I have to do by collapsing or folding the irrelevant code. Code folding was present in the first version of Builder, but it didn't preserve the folded state of the code when you closed the file: Builder 2 does.
The biggest non-editor improvement in Builder 2 is the search functionality Adobe added to the IDE. The search tools in Builder 1 were the default search tools in the Eclipse platform: the simple Find/Replace dialog window for doing text or regular expression searches within the current file, or the more global text/expression search dialog brought up by hitting Control-H in the Navigator view. The Eclipse global search option is still available in Builder 2, but Adobe created their own search box to handle both current file and multi-file searches:
This new search box, which I can bring up by hitting Control-F (Windows) or Command-F (Macintosh) anywhere in my editor window, is modeled after the search dialog in Adobe Dreamweaver but with additional features. The Scope drop-down box gives me almost complete control over the scope of my search. I can limit the search to the local document or have it search all open documents. If I choose the "Projects" or "Workingset" option, I can select one or more projects/Eclipse workingsets to search as well as the type of files to search. I can even search files outside of the Eclipse environment, including files located on an FTP server (though I haven't tried that option).
The search box defaults to searching for a single line of text, but if I'm searching for a particular piece of code that spans multiple lines, I can conduct a multi-line search:
I also have the option of doing a tag-based search rather than a text search. This is a really powerful feature in certain circumstances. Say I have several <cfldap> tags in my project that query my LDAP server. Each of the tags connect to the same LDAP server but certain settings differ between each tag, like the two examples below:
<cfldap action="query" name="garyQueryObject" server="myLdapServer.com" username="East12" password="Secret" filter="(firstName=Gary)" attributes="firstName,lastName,email"> <cfldap action="query" name="paulQueryObject" username="West12" password="NotAsSecret" server="myLdapServer.com" filter="(firstName=Paul)" attributes="firstName,lastName,email">
Say things have changed, and my LDAP server now has a ".org" address instead of a ".com" address, so these tags need to be updated. With the new search feature, I can define a tag-based search to find all tags where the "server" attribute is set to "myLdapServer.com" and change just the server name:
All of these additions and enhancements (and there are a few others I didn't mention) have helped me to write cleaner code faster and to remove some of the tiny distractions (the forgotten function argument, the extra typing to make the code look organized) that disrupt the flow of my coding. For me, that's enough to make ColdFusion Builder 2 a worthy improvement over the original version.
Opinions expressed by DZone contributors are their own.