CFCs don't have true constructors at this time. To make up for that, several people have standardized around the idea of a method called init(), but it's up to the programmer to call init(); the system doesn't do it itself.
Hal Helms See halhelms.com for classes in... Java for ColdFusion Programmers Fusebox 4 Mach-II OO Applications with CFCs -----Original Message----- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2003 2:58 PM To: CF-Talk Subject: RE: CFC/Object Best Practice That is indeed what I was trying to figure out. Got almost there myself. I'm wondering about your constructor? <!--- "constructor" ---> <cffunction name="init"> <cfset variables.engine = createobject("component", "Engine")> </cffunction> I was under the impression that CFC did not have a true "constructor", but rather a psudo-constructor in that code between the <cfcomponent> tag and the first <cffunction> tab would be run once when the component is used. Is this correct, or is there something special about a function named "init"? -------------- Ian Skinner Web Programmer BloodSource Sacramento, CA -----Original Message----- From: Tim Blair [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2003 9:44 AM To: CF-Talk Subject: RE: CFC/Object Best Practice > And how would this look in the code of a CFC? I'm guessing what you mean is something like this: <cfcomponent name="Car"> <!--- "constructor" ---> <cffunction name="init"> <cfset variables.engine = createobject("component", "Engine")> </cffunction> <!--- a function which calls something from the engine ---> <cffunction name="checkOil"> <cfreturn variables.engine.getOilLevel()> </cffunction> </cfcomponent> ? Tim. ------------------------------------------------------- RAWNET LTD - Internet, New Media and ebusiness Gurus. Visit our new website at http://www.rawnet.com for more information about our company, or call us free anytime on 0800 294 24 24. ------------------------------------------------------- Tim Blair Web Application Engineer, Rawnet Limited Direct Phone : +44 (0) 1344 393 441 Switchboard : +44 (0) 1344 393 040 ------------------------------------------------------- This message may contain information which is legally privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. ------------------------------------------------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com

