TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

ColdFusion Makes Hard Things Very Easy

5 Comments

This is not the first time I've made the claim that ColdFusion makes things easy. This has been my chief reason for loving ColdFusion from day one. I'm going to take a few tasks, and show you how easy ColdFusion makes them.

Get some data out of a database and display it on a page:

<cfquery name="results" datasource="cfartgallery">
   SELECT    firstName, lastname
   FROM    app.artists
</cfquery>

<cfoutput query="results">
#FirstName# #lastName#<br />   
</cfoutput>

Querying from a database using CFQuery just feels natural and easy. I personally hate saving SQL to a string, then attaching it to query object that I then execute. Looping over the results of query is also simple and straightforward. I don't have to worry about addressing the query in a collection or other structure, CFoutput handles looping over the results and pointing my call of "firstname" to the firstname column in the current row of the results.

Send a short email to someone:

<cfmail to="terry@terrrenceryan.com" from="terry@terrenceryan.com" subject="A test mail">
   This is a test message
</cfmail>

Similar to the database query, sending mail from ColdFusion is just drop dead simple. More than that, it's pretty intuitive. It's hard to not understand what is going on here.

These are pretty standard, and most tools have patterns written for them to make this sort of basic functionality easy to write. So let's take on some harder tasks.

Create a PDF from some content:

<cfdocument format="PDF">
   <p>Hello World</p>
</cfdocument>

I contend that printing a document to the PDF Print driver takes more effort than doing it in ColdFusion. Feel free to disagree.

Create an image for use in CAPTCHA testing:

<cfimage action="captcha" text="rEadMe">

Notwithstanding everyone's hatred for CAPTCHA, that's shockingly easy to create a CAPTCHA image.

Okay, again nothing we did was too crazy but you have to admit that is some really easy, concise, easy to comprehend code. Let's do something a little harder.

Pull all appointments named "Lunch" from your Exchange Server:

<cfexchangeconnection action="open" connection="exConn"
      server="#mailhost#" mailboxName="#mailbox#"
      username = "#username#" password = "#password#" />


<cfexchangecalendar action = "get" name = "calendar1" connection = "exConn">
   <cfexchangefilter name="subject" value="Lunch" />
</cfexchangecalendar>

I've said it before, the only way of working with Exchange that is easier than ColdFusion is Outlook.

Pass a result generated from .Net to a Java string for use by a custom Java Library:

<cfset pwd = CreateObject(".Net", "System.IO.Directory").getCurrentDirectory() />
<cfset jString = CreateObject("java", "java.lang.String").init(pwd) />

Interoperability between .Net and Java, in two lines of code? That's kinda ridiculous.

Now, to be clear here, I'm not saying you can't do all of this in other languages, I'm saying this is the easiest I've ever seen it done. The team behind ColdFusion has done a great job of balancing between encapsulating the difficult, but making it easy to go beyond what they enabled. All of the tags used in the examples have many more attributes that you can use to fine to the behavior show off here.

This was a overview of how easy ColdFusion makes it to do hard things, in the next series post I will talk more about what you can do with ColdFusion when ColdFusion can't do what you want it to do. (That's not a typo.)

5 responses so far ↓

  • 1 Sam Farmer

    Nice entry. I touched upon some similar themes with this 10 CF One-Liners post:
    http://samfarmer.instantspot.com/blog/2007/8/1/Ten-ColdFusion-8-OneLiners
  • 2 Terrence Ryan

    Thanks Sam, I hope I didn't steal anything inadvertently.
  • 3 Sam Farmer

    @Terry: Oh, not at all. Just wanted to post more examples of the power of the CF! :)
  • 4 Kevin Hoyt

    Nice work, Terry!

    Perhaps we should have a web site "makeshiteasy.com" where there's just a gazillion crazy examples of how it just ain't easier than with CF. My personal favorite is the oft forgotten query of queries, but I dig your .NET to Java in two lines too.

    Kevin
  • 5 Steven Erat

    Great to see so many ColdFusion blog entries this week!

    Here's my homage to how ColdFusion makes hard things easy:
    http://farm2.static.flickr.com/1205/1462403613_3a8338e429_o.jpg

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed flash builder air mobile android adobe apptacular html5 driving technical change running a coldfusion shop adobemax06 movable type flash catalyst flash blackberry adobemax07 adobemax08 hero finicky css adobemax09 holy crap i’m a mobile developer centaur basecamp cfc unfuddle motorola metablog irrational characters ios git evangelism devices code reviews ant wharton subversion security phonegap philly philadelphia multidevice knowledge@wharton jobs browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile java it github flexorg fireworks edge eclipse dreamweaver apps apple adobemax11