I would add your component is now completely mutable.  A developer can 
add any data they want which may or may not be a big deal depending on 
ones thinking on such things and what the component is meant to do.

An example that shows this code is going to accept any and all input 
such as this.
aObj.set("myOwnSillyvar","Some really bad data")

Ian


Ben Nadel wrote:
> Chris,
>
> While I don't know what is *right*, here are the arguments that I have
> heard against the generic getter/setter:
>
> * The CFC is not self documenting. Looking at its functions does not
> give you any insight into what it can set/get.
> * Not clear on what should be returned if an invalid "get" is requested.
> * It makes extending a component more difficult because the parent
> component now has to be smarter about where it looks for its data.
>
> Take that with a grain of salt ;)
>
>
> ......................
> Ben Nadel
> Certified Advanced ColdFusion MX7 Developer www.bennadel.com
>  
> Need ColdFusion Help?
> www.bennadel.com/ask-ben/
>
> -----Original Message-----
> From: Peterson, Chris [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 09, 2007 3:52 PM
> To: CF-Talk
> 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
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283314
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to