I posted this to the COAL mailing list last night: I had an epiphany of sorts today after a conversation on cf-talk. Its something that I have known for a long time in the back of my mind, but never fully realized it. First a little background. You cannot duplicate or copy components. Components (objects) are passed by reference, not by value. And the duplicate() method doesn't work on objects. If you aren't with me, consider the following code. <cfset variables.x = createObject("component","myObject").init() /> <cfset variables.y = variables.x /> If objects were passed by value, variables.y would hold its own copy of the object. But since objects are passed by reference, variables.y and variables.x hold the exact same object. So If we make a change in variables.y, the change was also made in variables.x. So why is this a problem? Because in COAL, I implemented part of the service locator pattern that is the caching agent. Which makes sense in the service locator pattern, because the pattern is working with _services_, not objects. Services are stateless. You can create objects out of them, but they should have no instance data. They are also singletons, and only one copy should exist per application. So if the code was to request a service that has already been created, it should give them the exact same copy of the service, not a new one. But this doesn't work with the objects that COAL is supposed to create. So basically the caching agent in COAL is useless, and should not be used. I haven't run into any problems with COAL yet though, because I always turn caching off anyway. But I am sure if I was using the caching, it would have caused problems by now. So, sorry for that long explanation, but this is whats going to happen. The service locator pattern is still great for COAL in the way that you can request just the object name (that you have given it in the config xml document) and get it to know where the component is stored and create the object for you. So we are just going to take the caching agent out of the "framework" code. I am going to leave the cache attribute in the coal.cfc init() for now for backwards compatibility, but it will basically be disabled, no matter what you give it there will be no cache. So the implementations you already have wont break, just that functionality (which is and should be transparent at this point anyway) will just cease to exist. You should go ahead and take that attribute out if you are using it now because it will be taken out completely in future versions. Sorry about this dumb mistake guys. But it should all be fixed pretty easily by this weekend. Any comments or suggestions on the matter are welcome.
You are looking at a blog entry named “You cannot make a copy of an object in CF!” that was published on Tue. September 27, 2005 on aDeepBlue.com.
- 2012 March
- 2009 December
- 2009 November
- 2009 September
- 2009 May
- 2009 April
- 2009 March
- 2009 February
- 2009 January
- 2008 December
- 2008 November
- 2008 October
- 2008 September
- 2008 August
- 2008 June
- 2007 November
- 2007 October
- 2007 August
- 2007 May
- 2007 March
- 2007 January
- 2006 December
- 2006 November
- 2006 October
- 2006 September
- 2006 August
- 2006 July
- 2006 June
- 2006 May
- 2006 April
- 2006 March
- 2006 February
- 2006 January
- 2005 December
- 2005 November
- 2005 October
- 2005 September
- 2005 August
- 2005 July
- 2005 June
- 2005 May
- 2005 April
- 2005 March
- 2005 February
- 2005 January
- 2004 December
100m 1dsMkIII 200m 50D 5dMkII 8-bit adb Adobe ai airports alecsoth AMF animals animation apple art AskAnEmperor audience audio audio indexing b&w banjo banksy basketball bedding bicycle blog blogshares braid brain browser bungie canon car cars cascade cdc census cf.objective cfdirectory cfssp Chris O'Shea chrome COAL coldfusion color commands common sense dashboard data visualization database David Dunlap db depthoffield design dictionary diegogarcity dna earth eclipse election election08 email energy english envelope paradox Erin McKean exercise f1 fashion firefox flex flickr flickr commons flip video flobots flu food football ford friendfeed funny futuristic g-speak games gaming genetic programming gmail google grafitti graph paper halo hd health high-speed honeymoon House humanity hurricane IE 7 infographic intel internet iphone ironman jamaica Java JAXA jazz Johnny Chung Lee kickstarter kodak lensbaby lexicon LIFE light-switch linkage macromedia Macy's map marinara math MAUG Mechanical Turk medical medicine mersenne Michael Johnson miles davis mirror misc model-glue money movies music mxna mysql neuroplasticity neuroscience New York New York Times news nexrad nike+ nyt oblong olympic record olympics OOP OSX paducah paradox pasta pdf PDFPad personal photography photoshop placebo politics poll pownce prediction previous blog primes probability projects protip qbrowser quote racing radar rain red bull red video remoteObject eventHandlers running ryanguill sandals resort schema-less science search search engine senses sheets ship skateboarding skynet software space sparklines spore sports SQL squirt guns starwars stock-market stupid subversion superbowl tdwr tech technology TED terminal thoughts tilt-shift track and field trends tshirt twitter two envelopes problem ui Usain Bolt user interface vacation video vimeo vincent laforet wealth weather web webkit wedding weird weird news wierd wii wikipedia wired wolfram alpha words xbox XML xprize Yann Arthus-Bertrand zeitgeist zoo

1
Yes, however Query Objects are copied using deep-copy whenever a Query Object is assigned from one Scope to another such as in this example: <cfscript> Request.q1 = q1; // assumes q1 is a Query Object </cfscript>