I like to think a lot about Rapid Development.
Programming I find to be very enjoyable. I enjoy thinking around problems and designing proper solutions.
I also enjoy adding processes and techniques that allow me to write better code faster. Today, we will focus on using snippets in CFEclipse to develop in a rapid fashion.Snippets, put simply, are code segments that can be customized and inserted into your source code with a minimal of effort. Often we need to write a block of code following a particular pattern, such as get/set methods. We then locate a similar block of code, copy it, paste it into the new code then change the variable names and other bits to fit the idiom. Rather than this somewhat error prone technique, we can use a snippet.
Below are my top 7 snippets that I use on a regular basis. Feel free to modify each to represent your stylistic needs.
- Trigger: arg
- Purpose: create an argument declaration for a cffunction
- Trigger: da
- Purpose: Dump a variable and halt processing. Also puts the Unique Value into the show error attribute of cfabort
- Trigger: fun
- Purpose: create a cffunction
- Trigger: get
- Purpose: create a cffunction using a ‘getter’ pattern
- Trigger: set
- Purpose: create a cffunction using a ‘setter’ pattern
- Trigger: getset
- Purpose: create an argument declaration for a cffunction
- Trigger: qp
- Purpose: create a cfqueryparam tag definition
These seven snippets are included in a zip file. You may download it by clicking the ‘download’ link at the bottom of this post. If you already have snippets, then DO NOT Copy over keyCombos.properties. The other 7 files can be added in to the directory with little chance of conflict. You will have to manually edit each snippet to put in the trigger text and the name/description. (You *COULD* try to merge the keycombos.properties files, but I assume no liability)
To install, open up your workspace directory and unzip the files in the following directory:
{WORKSPACEROOT}.metadata/.plugins/com.rohanclan.cfml/snippets
For more information on tweaks, configurations, snippets and other CFEclipse information, please have a look at the CFEclipse Trac Wiki
Also, a pragmatic tutorial on how to use snippets