Sam Farmer head shot

Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

But I have become a passionate and pretty good web developer.


Next release of ColdFusion has websockets, closures, enhanced security, REST and more

At Adobe MAX the ColdFusion team showed off some of the planned features in the next release code-named "Zeus". Highlights include:

  • More security functions (using ESAPI)
  • Closures
  • REST built into components (classes). From the example shown specify a couple arguments to a function and it becomes a REST service.
  • Websockets
  • HTML 5 Charting (including a demo showing updating a chart via websockets — in the Keeping Current video below)
  • Tomcat as default engine

After viewing both videos this is not the full list for ColdFusion Zeus but a nice primer of what is to come (and includes standard disclaimers that things may change).

The Videos

Keeping Current with ColdFusion — Provides a quick overview of ColdFusion 8 & 9 but mostly covers what is in Zeus.

What's Next in ColdFusion — Focused solely on ColdFusion Zeus and covers a lot of the new features

How I Got Started in ColdFusion

I needed a quick way to create cheap energy and so...

Ok, cheap joke out of the way. ColdFusion was the third language that I tried and I was impressed at how much I could easily. I had been hired without ever writing a line of ColdFusion and so was taking a bit of a gamble that I could do it (as was the company!). I was able to pick it up pretty quickly. I put this down to working for a great company and with some colleagues who knew more than I did. I was learning stuff, doing cool stuff and having fun.

That was with version 3.1. Since then I've learnt some stuff, written some cool stuff and had fun. And written the odd bug or two. Before ColdFusion I had written two other languages.

The first piece of programming I did was with JavaScript. This was back in 1995 and I remember getting excited that I could write a script that would display the date and time in a nice format. I did some programming in high school with, I think, BASIC but all I remember was changing the color of text and using GOTO and being pretty unimpressed with it all.

The second language I used was Perl (I'm ignoring HTML and SQL for this post). I had an assignment at work to produce hundreds of reports. The initial plan was to do this by hand but someone suggested using Perl and the next thing I was off on a Perl training class. I loved it. The ability to write a script and have all these reports come out was great. At that point I was truly hooked on being a programmer.

RIACON is less than two weeks away; Register NOW!

With 25 sessions spread over three tracks — ColdFusion, Flex and jQuery/Javascript — RIACON is shaping up to be a great conference.

This is the inaugural conference and the registration cost is $99. How can you not want to come? Register now

I will be talking on jQuery and Media Queries: Optimize your site or app for every screen size

Adobe Commitment to ColdFusion Shown in Financial Report

From Adobe's latest Form 10-K is, amongst other mentions of ColdFusion, the following quote:

Our ColdFusion business improved during fiscal 2010 due to the improving macro-economic environment, as well as due to continued innovation in the products' feature sets to address the evolving needs of ColdFusion developers. We will continue to invest in the capabilities ColdFusion platform in fiscal 2011 to maintain and grow revenue in this market.

I am no financial expert but a Form 10-K is signed off on by Directors and above at any publicly traded company and filed with the Securities and Exchange Commission. This is not a marketing statement or a blog entry from "someone in the know", these are statements that if given falsely could place the company and directors in trouble. It is a clear, definitive statement that Adobe is committed to and investing in ColdFusion. Huge hat tip to Rob Brooks-Bilson for this one.

Thoughts on the Change in Product Manager for ColdFusion

Since 2000 there have been three ColdFusion product managers; Tim Buntel until February 2006, Jason Delmore from April 2006 to December 2008, and Adam Lehman from February 2009 until...now.

Each time a new guy came in ColdFusion got better, more vision is added and the next release surpassed the previous one. In sports there is a saying that "no one is bigger than the team" and it is a saying that is true to many other things as well such as languages or products. ColdFusion is way bigger than any one person. The development is done by a big team with a wonderful community around it surrounded by hundreds of thousands of developers.

There is also a pattern to ColdFusion releases. There is a period of reflection and vision setting and of talking to customers. Then comes the actual development, testing, betas, releases. It is pretty clear where ColdFusion is right now. Spend some time on this blog post by Adam and the new vision sounds very exciting. And Adobe is upping resources to meet that vision.

I spend a fair amount of time outside of work, playing with and testing ColdFusion and writing blog entries. I plan to keep on doing that. The future is exciting.

Mr. Camden Goes To Washington (Capital Area ColdFusion User Group)

Ok, so the title is a play on Mr. Smith Goes to Washington (and one that is overplayed) but next Tuesday Raymond Camden is coming up to present at the recently formed Capital Area ColdFusion Users Group on a very interesting topic:

Ray Camden: Practices of a Modern Developer

Everyone knows what good developers do, but it isn't always obvious why. In this session, Raymond Camden will talk about the practices that are considered best practice (source control, unit testing, load testing, etc) and more importantly, why they are considered best practice. Practical examples of the benefits of these practices will be provided.

Details here.

Eager readers may notice that this is actually in Crystal City and technically not Washington. 

Dynamically injecting data into an Object

I like to write as little code as possible (that’s the whole point of coding, right?) and recently, since I started working with ORM, have found the need to inject data into an object. Often with an ORM object -- though this isn’t limited just to ORM -- you create a new object then have lines of setXXX functions like so:
 
s = entityNew( 'Sample' );
s.setAge( form.age );
s.setFirstname( form.firstname );
 
Well I got pretty bored of writing all those setXXX lines. So I wrote a function to do it. (This is not the only way or necessarily the best way but I thought I would put it out there).
 
<cffunction name="injectInto">
<cfargument name="obj" required="true" hint="I am an object for injecting">
<cfargument name="st" required="true" hint="I am a structure of data.">
<cfloop collection="#arguments.st#" item="local.key">
            <cfif structKeyExists( obj, "set#local.key#" )>
                        <cfinvoke component="#arguments.obj#" method="set#local.key#" >
                        <cfinvokeargument name="#local.key#" value="#arguments.st[ local.key ]#">
                        </cfinvoke>
            </cfif>
</cfloop>
</cffunction>
 
First off this is all in tags as there is no invoke function in cfscript. Originally the if structKeyExists line was a try and catch. That worked but felt a little like overkill so I experimented around and found that structKeyExists works as I blogged about. I also tried using getComponentData which returns all functions but again this felt heavy to me.
 
So, what does the function do? It takes in an object that you want injected and a structure of data to inject into it, loops over that data, checks to see if the object publicly wants it and if so uses cfinvoke to give it to the object. The above code now becomes:
 
s = entityNew( 'Sample' );
s injectInto( s, form );
 
But what if you have data in multiple structures; form, url, request for instance? 
 
<cffunction name="injectInto">
<cfargument name="obj" required="true" hint="I am an object for injecting">
<cfloop from="1" to="#structCount( arguments )#" index="local.collection" >
            <cfif isStruct( arguments[ local.collection ] )>
                        <cfloop collection="#arguments[ local.collection ]#" item="local.key">
                                    <cfif structKeyExists( obj, "set#local.key#" )>
                                                <cfinvoke component="#arguments.obj#" method="set#local.key#" >
                                                <cfinvokeargument name="#local.key#" value="#arguments[ local.collection ][ local.key ]#">
                                                </cfinvoke>
                                    </cfif>
                        </cfloop>
            </cfif>
</cfloop>
</cffunction>
 
The above function will take in any number of structures and inject their data into the object. You may notice that the function only has one argument even though I just said it can have an endless number of arguments. That’s because I am going to programatically deal with them.
 
Regardless of how many arguments a ColdFusion function has defined it will always take in everything you give it. (Its generous like that! ;) ) If the arguments are not named then they take a number in the arguments structure. Let’s call the above function and then dump its arguments passed into injectInto.
 
//setting up some “fake” structures for form, url and request
f = { age="23" };
u = { firstname="Sam", age="21" };
r= { userID=2134132 };
sObj = new Sample();
injectInto( sObj, f, u, r );
 
 
As you can see the only named argument is the first one passed in – obj, the others get numbers for names. This is useful as it preserves the order they are passed and means we can loop over them and inject their data into the object which going back to the injectInto function is exactly what happens.

Using StructKeyExists to find if an object has a function

Recently I have needed to dynamically know if an object has a public function. I found this can be achieved using structKeyExists. First, lets set up a cfc:
 
component accessors="true"
{
property name="firstname";
property name="age";
 
private function getaddress() {
            return variables.address;
}
private function setaddress( address ) {
            variables.address = arguments.address;
}
}
 
Or if you prefer a tag based cfc:
 
<cfcomponent accessors="true">
 
<cfproperty name="firstname">
<cfproperty name="age">
 
<cffunction name="getaddress" access="private">
            <cfreturn variables.address>
</cffunction>
<cffunction name="setaddress" access="private">
            <cfset variables.address = arguments.address>
</cffunction>
 
</cfcomponent>
 
An object of this cfc will have 6 functions, 4 public ( getFirstname(), setFirstname(), getAge(), setAge() ) and 2 private ( getAddress(), setAddress() ).
 
Now based on getting errors when leaving off the parenthesis from a function call, I thought I would try and see if I could use structKeyExists to test if a function exists.
 
<cfset s = new Sample()>
 
<cfif structKeyExists( s, "setFirstname" )>
            The function setFirstname EXISTS!!<br>
<cfelse>
            The function setFirstname can not be accessed or does not exist<br>
</cfif>
 
<cfif structKeyExists( s, "setAddress" )>
            The function setAddress EXISTS!!<br>
<cfelse>
            The function setAddress can not be accessed or does not exist<br>
</cfif>
 
This will output:
 
The function setFirstname EXISTS!!
The function setAddress can not be accessed or does not exist
 
I was a little surprised it worked and can’t decide if its hackey or cool (or if hackey is even a word!). Next up I’ll show why I wanted to do this and use it dynamically.

Speaking at CF in NC...Come Along and Enter to Win a Flip CF Dude Camera

I am delighted to have been chosen to present at the CF in NC conference in October on the topic of "One Liners in ColdFusion".  Its a topic I enjoy, one that I've blogged about and one that Joe Rinehart mentioned in his excellent keynote on day two of CFUnited.

The session line up at CF in NC conference is very exciting and if you can make it I suggest coming along.  There is even a chance to win a CF Dude Flip Video Camera.

My 30onAir Video

30onAir is a rather fun site where developers explain why they love certain technologies like CF, Flex, Air, AJAX, etc. Here is my CF attempt:

Previous Entries / More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner