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.
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:341971
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm