Returning ColdFusion 9 ORM objects with JSON

Last week I was working on a client’s project that makes heavy use of ColdFusion 9’s ORM features. Everything we’d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in the project where I needed to be able to use AJAX calls from jQuery to manage some of the data in the database. Based on my experiences using a RemoteFacade.cfc to feed data to a Flex app, I thought it should be pretty easy. Several hours later, I realized that my particular use case for this was anything but easy.

Read More

Embracing “New” in ColdFusion 9

I’m not sure how I missed this before but among the long list of things added to ColdFusion 9 is the ability to create a CFC using the “New” syntax. Up until now, to create a new object from a CFC we’d use the createObject() method like so

<cfset Team = createObject("component", "model.Team") />

Now, using the New keyword, we can shorten that to

<cfset Team = New model.Team() />

But wait, there’s more!
When you use the New keyword, ColdFusion will automatically look for and run any init() method that exists in the CFC. It also respects any arguments that your init() method specifies, meaning that if you have a Team.init() method that can accept team name, color and manager arguments, you can build them right into your the same line of code used to create your object like so

<cfset Team = New model.Team( "Bumblebees", "Yellow", "Benny Bee" ) />

Likewise, as you’d expect, named arguments are still supported. So if you had to send in arguments out of order or needed to omit some optional arguments at object creation, you could do

<cfset Team = New model.Team(
              manager="Benny Bee",
              color="Yellow",
              name="Bumblebees") />

I personally am going to make a point to start using this in my code because I can never seem to spell the word “component” correctly in the createObject() method.

My ColdFusion Anniversary

Well, not quite yet, but since I’m going to be out of pocket the next several days, I wanted to put this out now. Monday, March 22 will mark 10 years since I began my “journey” with ColdFusion. That day in 2000 was my first day in a class called “Fast Track to ColdFusion”.

The class was taught by Sean Hedenskog in San Jose, CA where the headquarters for the company I was working for at the time was located. That company had decided on Allaire Spectra 1.0 as the basis for an enterprise content management system so several of us went through the Fast Track to ColdFusion course in preparation for Spectra training some weeks later.

Read More

Can you code with 9 fingers?

That’s what I’m doing today thanks to a relatively freak accident with a staple gun yesterday. I won’t bore you with the details (that would confirm what a bonehead I can be sometimes). Just suffice it to say that, it could have been a lot worse.