> I know that var scoping is paramount with CFC development, however, I do have 
> a question in regards to var scoping when the CFC is not going
> to be a singleton and the impact that might have.
>
> Please consider the following simplified example:
>
> <!--- mySingletonCFC.cfc --->
> <cfcomponent name="MySingletonCFC">
>   <cffunction name="doSomething">
>     <cfset var MyObj = createObject("component", "MyNonSingletonCFC").init() 
> />
>     <cfset MyObj.doSomethingElse() />
>   </cffunction>
> </cfcomponent>
>
> <!--- MyNonSingletonCFC --->
> <cfcomponent name="MyNonSingletonCFC">
>   <cffunction name="doSomethingElse">
>     <!--- in here there are some non var scoped parameters --->
>   </cffunction>
> </cfcomponent>
>
> In this example doSomething() creates a new object and then calls 
> doSomethingElse() in the new non-singleton object.  Inside
> doSomethingElse() there could be non var scoped variables.  While I 
> understand this is not good practice nor recommended, am I also correct in
> assuming that you could run into issues b/c the variables are not private to 
> the function call?  Or because the CFC always will be created with
> each invocation of doSomething() will it be ok.

It will be ok, as you're creating a new separate instance of your
non-singleton CFC for each call to doSomething.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, onlin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341992
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to