Well that isn't going to work for all variable types and seems a little clumsy.
This method relies on top much which may not be present in a more complex CFC application setup. "This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant, Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions." Visit our website at http://www.reedexpo.com -----Original Message----- From: Peterson, Chris To: CF-Talk Sent: Mon Jul 09 20:51:48 2007 Subject: Init method and getters / setters in cfc A lot of cfc's using init and 'good' OO practices have functions like getDSN(), setDSN('Blah') littered throughout. Can I ask any guru out there why you wouldn't use simple get('keyname') and set('keyname','keyvalue') like the following? <cffunction name="get" access="public" output="no" returntype="any"> <cfargument name="name" required="true" type="string"> <cfreturn evaluate('variables.' & arguments.name) /> </cffunction> <cffunction name="set" access="public" output="no" returntype="void"> <cfargument name="name" required="true" type="string"> <cfargument name="value" required="true" type="any"> <cfset variables[arguments.name] = arguments.value /> </cffunction> Then instead of littering your cfc with numerous getters / setter, you have 2 methods that should be able to handle simple or complex values without any problems with much less code. Chris Peterson Gainey IT Adobe Certified Advanced Coldfusion Developer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283308 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4