Productivity with ColdFusion
Monday October 29, 2007 ·
1082 views ·
0 comments
With recent articles proclaiming Coldfusion to be dead or dying, there have been several 'rebuttal' posts by members of the CF community. Many of those rebuttals did a good job of showing other readers that Coldfusion is alive and kicking. One theme that constantly came up was that Coldfusion enables you as a developer to be more productive. In my opinion, I couldn't agree more. I think it's really hard to drive home the point of Coldfusion and productivity to non-CF developers without throwing concrete examples in front of them to see first hand. Many of the skeptical readers won't spend the time to figure out on their own if that statement is true or not, most will probably see it as "my language is better than your language" flame bait. I don't blame them for thinking that way given the pretense of the article and no examples to prove it. My attempt with the rest of this post is to help back up the claim that CF enables you to be more productive. I tried to choose examples of task that are sometimes trivial but also part of the average everyday development. Language Verbosity Querying the Database Coldfusion will implicitly and efficiently manage datasource connections for you, alleviating the need for you to explicitly open and close connections to the database yourself. This means that you don't have to waste time coming up with a strategy (and coding for) connection management or connection pooling, with CF it's built in and configurable. This definitely saves time when you are dealing with extended 'sessions' and/or accessing multiple data locations. On top of the connection handling bit, the attribute 'cachedWithin' will cache any given result set for a specified length of time. No extra classes, frameworks or sql semantics are needed, Coldfusion gives you caching capabilities with a single attribute. Grouping Query Results for Display Take for example the data set below, it represents a list of members and the services they have payed for. memberid memberName serviceName serviceCost Your client might want to see the results in a typical alternating row fashion like the ones below.
To achieve this kind of grouping in the display you typically have to come up with some type of conditional logic to determine when to start the next member. This isn't overly complex logic but none-the-less it has to be written. In Coldfusion you don't need to even think about it. With the editing u need the 'group' attribute and an extra set of output tags. CF can group on any column returned in the result set and achieve the desired output without conditional logic. The example above is probably not best one to show how this can be a time saving feature of Coldfusion, but it does show you can retain clean code in the face of scenarios like that which over time increase productivity due to clean readability.
'Dumping' an object Uploading a file to the server The 'filefield' attribute holds the html form field name used for the file and the 'nameConflict' attributes controls how CF will handle the upload when another file already exists with the same name. Other 'nameConflict' values can be "Error" to throw an exception, "skip" to do nothing and "overwrite" to overwrite the contents (default behavior). In addition, the <cffile> call above will return a container with a ton of information about the uploaded file. Here is are the attributes that are provided:
Working with Web Services Working with web service can sometimes be complex and a pain. This is especially true when dealing with SOAP based service. Many developers are shying away from them for the more simplistic REST model because they are easier to consume and publish but with Coldfusion, working with SOAP services couldn't be easier. The WSDL for this service is auto generated and is immediately available for consumers, simply navigate to the containing Coldfusion component (cfc) and append 'wsdl' to the query string, for example http://www.mysite.com/location/to/Service.cfc?wsdl. Consuming Services Just like publishing, consuming a service is extremely easy. The example below shows how you might consume a service that looks like the one above. After the web service call, the variable 'results' will hold a local copy of the 'MyCustomObject' object returned from the service. The examples that I covered are only a small subset of the many ways that CF can enable you to be more productive. It's combination of features and abstractness make it possible for developers to get more done in less time, hence Coldfusion enables developers to be more productive. Comments
"What happens is not as important as how you react to what happens." - Ellen Glasgow
Recent Reads |



