I was amazed to find out that keyword new was not a reserved word. I was fairly certain that it was not a keyword that is being used but I thought It may be reserved for latter use. With that being said and my new found love for cfcUnit (more on this later kids!) I now have a cool little utility function. Again, I got the idea from cfcUnit as they use the newObject() form. So I alway have a base class for each project that all other components or other base classes will extend. In this base class I like to have little helper functions and this new one is a great one. Here is the code to my base component.
view plain print about
1<cfcomponent name="BaseComponent">
2    
3    <cfset NULL = "">
4    <cfset variables["_objectID"] = CreateUUID()>
5    
6    <cffunction name="new" access="public" returntype="WEB-INF.cftags.component">
7        <cfargument name="type" type="string" required="true"/>
8        <cfargument name="object" type="string" default="component">
9        <cfset var ret = "">
10        
11        <cftry>
12            <cfset ret = createObject(arguments.object, arguments.type)>
13            
14            <cfcatch type="coldfusion.runtime.CfJspPage$NoSuchTemplateException">
15                <cfthrow type="Exception.NoSuchComponent" message="Could not find the component '#arguments.type#'"/>
16            </cfcatch>
17            <cfcatch type="any">
18                <cfthrow type="Exception.Instantiation" message="Could not instantiate object of type #arguments.type#" detail="#arguments.type#"/>
19            </cfcatch>
20        </cftry>
21        <cfreturn ret>
22    </cffunction>
23    
24</cfcomponent>

This is a really good time saver because now anytime I need to instantiate any objects in any cfc that extends my base its really easy to do.

view plain print about
1<cfcomponent name="BaseTest" extends="BaseComponent">
2
3    <cfset variables.shoppingCart = "">
4    <cfset variables.dsn = "">
5    
6    <cffunction name="init" access="public" returntype="BaseTest">
7        <cfargument name="dsn" type="string" required="true">
8        <cfset variables.dsn = arguments.dsn>
9        <cfreturn this>
10    </cffunction>
11    
12    <cffunction name="getCart" access="public" returntype="any">
13        <cfset variables.shoppingCart = new("ShoppingCart").init(variables.dsn)>        
14        <cfreturn variables.shoppingCart>
15    </cffunction>
16    
17</cfcomponent>