I was recommended to build a Factory object to create my CFCs in the following manner:

 

<!--- init --->

<cffunction name="init" access="public" returntype="SystemFactory">

            <cfreturn this />

</cffunction>

 

<!--- load --->

<cffunction name="load" access="public" returntype="any">

            <cfargument name="ObjectName" type="string" required="yes" />

 

            <cfset var ObjectInstance="" />

 

            <cfinvoke method="create#arguments.ObjectName#" returnVariable="ObjectInstance" />

                       

            <cfreturn ObjectInstance />

</cffunction>

 

<!--- createObjectXXX --->

<cffunction name="createObjectXXX" access="private" returntype=" ObjectXXX ">

                       

            <cfset var Object=createobject('Component','SystemCFC.ObjectXXX).init() />

                                               

            <cfreturn Object />

</cffunction>

 

The load() method takes a CFC name and calls the appropriate Create() method. My app should only call load().

 

First off is this a good way? Secondly, if I use this way I seem to lose the ability to pass already instantiated objects to my init() methods - ofcourse I can still create new dependent objects and pass them in, which is the point of the whole thing, but what about passing in already instantiated objects? How does that work with Factories?

 

Anyone care to post a link to their Factory file ;-)

 

Cheers,

 

Baz

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to