The Most Important Enhancement in ColdFusion 8
Andrew Powell
ColdFusion 8 has a TON of new features, and they're all great. Some will help productivity and some will help with the GUI. However, there are a number of CFML enhancements that nobody has really talked about. For me, one stands head and shoulders above them all. It is the single most important enhancement to CFML since the introduction of CFCs.
What is it?
duplicate() now works on CFCs.
Let's stop and say that one more time, for effect.
duplicate() now works on CFCs.
What does this mean? It means, in geek speak, that we can clone or create a deep copy of a CFC. Until now, you could only pass CFCs around by reference (a pointer to the memory space occupied by the object) instead of by value. This will allow ColdFusion developers to do things like keep value objects in the application scope and take copies of them, when needed, for singletons.
Now, instead of going to createObject() each time we need a new object, we simply read the object out memory as a copy. A sample init function within a cfc (we'll call this one foo.cfc and assume it's in the root, for the sake of brevity) might look like this:
<cffunction name="init" access="public" output="false" returntype="foo">
<cfargument name="argumentA" type="string" required="true"/>
<cfargument name="argumentB" type="numeric" required="true"/>
<cfscript>
var returnObject = duplicate(this);
returnObject.setPropertyA(arguments.argumentA);
returnObject.setPropertyB(arguments.argumentB);
return returnObject;
</cfscript>
</cffunction>
This enhancement could have a lot of impact on the various frameworks out there (Peter, Matt, & Kurt are you paying attention?). There's a lot of createObject() going on in Mach-II, ColdSpring, Model-Glue, etc. This has the potential to help speed up your favourite framework, so applications you already have can benefit from this new feature once the frameworks are updated to use it.
To me, this is, easily, the most important new feature of ColdFusion 8. Well, this and CFTHREAD (no flame wars please Vince & Damon), but that's another post.
Posted in ColdFusion | General | ColdSpring | Adobe | Mach-II |
6 comments