Scott, That definitely helps!
-Aaron On 11/22/06, Scott Stroz <[EMAIL PROTECTED]> wrote: > Aaron, > > Functionally, there really is no difference between using the object factory > the way we did and instantiating an object in the application scope as you > are suggesting. > > When a variable, or object, is passed 'by reference', it simply means that a > new instance of the variable or object is not created, however a 'pointer' > is used to 'point' to the original variable. Here is a basic code snippet > that might help clarify. > > <cfset var1 = structNew() /> > <cfset var1.myName = 'Scott' /> > <cfset var2 = var1 /> > <cfset var2.myName = 'Aaron' /> > > <cfoutput>#var1.myName#</cfoutput> > > This code will output 'Aaron'. The reason is that var2 does not actually > contain a structure, rather just a 'pointer' to var1. > > In the objectFactory we used, when an object was 'registered' it was put > into a structure. When we call the create() method on the objectFactory it > checks to see if the object is supposed to be a singleton and if it is > already stored in the structure. If it is, it merely returns a pointer to > the object. As I said, while the code looks as if we are actually creating > a new object on each page where a gateway is needed, it is only created if > it doesn't exist or if you manually reinit the application. > > In a future presentation we will cover design patterns. In some design > patterns it would be more advantageous to use a factory like we did as > opposed to instantiating an object in the application scope. > > Hope this helps. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261425 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4