It's so trivial to generate the code for getters and setters that I don't
really see the point in having generic getters and setters like this. As Ben
says, you lose the API for your component. You have no type checking (if
that's your thing). You lose the ability to seamlessly change the getter or
setter later if the need arises. And if you want to use ColdSpring to inject
dependencies, you're either out of luck, or almost as bad, you have a mixed
API where some properties have their own setters and others use the generic
setter.

Also, an aside, there's no reason to use Evaluate() here. Just do <cfreturn
variables.instance[arguments.name] />.

Regards,

Brian

On 7/9/07, Peterson, Chris <[EMAIL PROTECTED]> wrote:
>
> 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
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283340
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