In this case I wasn't talking about inheritance though. Having a CFC whose sole purpose is to contain settings for the application helps in code reuse as multiple CFCs can call the method to get their settings. It also makes your constructor code simpler. Instead of having to pass the settings to each CFC, the CFC takes care of iteself. Your constructors can then focus on things thate are unique for each CFC.
A good example - your settings need to be modified. If you were passing your settings to the CFC, this means every piece of code that creates the CFC needs to be updated. If you get your settings _inside_ the CFC, then there is no need for this. You may have to update the code in the CFC for the new setting, but this is easily then updating N callers. On Sat, 13 Nov 2004 17:41:07 +0200, Murat Demirci <[EMAIL PROTECTED]> wrote: > > I recommend to use a variables.settings structure instead of getSettings(). > Because CF usually tends to use scopes/structures to make the development > easy (i think). You should set the settings structure in the constructor > method (the init()) method like the following: > > <cfcomponent> > <cffunction name="init" access="public" returntype="any"> > <cfargument name="settings" type="struct" required="yes"/> > <cfset variables.settings = arguments.settings /> > <cfreturn this /> > </cffunction> > .... > </cfcomponent> > > If you only need one or two specific settings in your component; you should > code your constructor like the following: > <cfcomponent> > <cffunction name="init" access="public" returntype="any"> > <cfargument name="dsn" type="string" required="yes"/> > <cfset variables.dsn = arguments.dsn /> > <cfreturn this /> > </cffunction> > .... > </cfcomponent> > > This is more easy for especially traditional CFers instead of extra > inheritance or methods which cause to lead unfamiliared codes; IMHO. > Additionally you can add your global settings structure and its context in > CodeHints XML file in DWMX to make faster coding. > Murat. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184221 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

