I had a hard time understanding passing by reference and by value in my Java class... I did download the code from Phill's blog and I couldn't figure out why you guys kept using the create method of the objectFactory on each page... now I get it.
However, in this thread I am asking a much more basic question. Why not just create the objects in Application.cfm and ditch the whole objectFactory thing? It seems like it would be a whole lot easier to just instantiate a gateway object in Application.cfm then it is to register and then create each object using the objectFactory. What am I missing? There always seems to be a good reason to make things harder when using OOP, so there has to be something too it, right? Thanks, Aaron On 11/21/06, Scott Stroz <[EMAIL PROTECTED]> wrote: > Aaron, > > Thanx for watching the presentation. I hope it helped you. > > The first part of the presentation was to demonstrate some OO principals, > and to show how you could transform a procedural application into one more > OO. It was during this part where we were creating all the gateway objects > when we needed them. In the latter portion of the presentation, we > discussed optimizing the application with the use of factories and caching > objects in a shared scope (the application scope). > > If you go to Phill's site, > http://www.phillnacelli.net/blog/index.cfm/2006/11/17/Central-PA-CFUG-Preso-Recapand > download the code, you will see that we used an object factory to > create > the gateway objects using the create() method. When these gateways were > used in the application, they are not being created, merely returned from > the object factory. Since the gateway objects were specified as a > 'singleton', only one instance of the objects will ever be in memory. In > the application files, when we once again called the create() method of the > object factory, it merely returned a reference to the object already cached > in the application scope (Remember, complex data types, including objects, > are passed by reference). > > So while the code on the some of the files may seem like new objects are > being created each time a page is hit, a look at the code in application.cfm, > and in objectFactory.cfc will show that the only time a new gateway object > is created is when one does not already exist, or if you manually reinit the > applciation by adding ?reinit=true to the end of a URL. > > On 11/21/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > > > > I watched a presentation from the guys at AboutWeb.com about Object > > Oriented Programming in Coldfusion and Phill Nacelli's Object Factory > > got me wondering a few things. > > > > Is it possible to initialize all of the object gateways into the > > application scope in Application.cfm? It seems like it would be better > > to create and initialize the object once and then reference it on each > > page instead of creating it on each page. > > > > In Application.cfm I would have: > > > > <cfset application.personGateway = > > createObject("component","path.personGateway").init(application.dsn) > > /> > > > > Then on the pages I would just do something like: > > > > <cfset getPeople = application.personGateway /> > > > > What do you think, am I off somewhere with all of this OOP stuff? > > > > -Aaron > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:261363 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

