Cody Caughlan said the following on 1/19/2006 1:44 PM:
>I seem to remember this subject coming up on this list before....search the
>archives?
>
>I am not a fan of this approach. As Larry Wall (creator of Perl) once said,
>"All programmers are lazy", we are always looking for shortcuts. "Hey, I am
>tired of writing stupid getters/setters!". And then an awesome tool like
>Rooibos Generator comes along and saves you HOURS of tedious getter/setter
>writing. Add a new property to an existing object is very easy with this
>tool.
>
>By encapsulating each property access in its own method(s) you have more
>control over how the object handles the internals. For some of my objects a
>basic setFoo() actually does more than a basic assignment, I do some
>internal calculations. Using the generic approach, your main add() method
>would be littered with an IF or SWITCH statement to handle this kind of
>"one-off" property handling. Eventually it would get tedious, error-prone
>and in-efficient.
>
>Its better to keep it all separate and use a 3rd party tool to generate the
>tedious cool for you.
>
>Rooibos Generator:
>
>http://rooibos.maestropublishing.com/
>
>/Cody
>
>
You're right...this subject has come up on the list before as I recall
participating in some discussion on it. Thanks for the kudos Cody.
I agree with you that I'm not a fan of this approach as well (method
#2). It can lead to some strange bugs. Take for instance...
<cfset myBean.setValue("fisrtName", "Peter") />
<cfset myBean.setValue("lastName", "Farrell") />
... more processing ...
<cfset iNeedFirstName = myBean.getValue("firstName") />
Notice anything...? Yeah, I misspelled firstName when I set it and now
when I try to get it...it's not there. If you try to call a setter
called setFisrtname(), it would error out....
I think that beans that do not have explicitly named getters/setters are
way too generic. Generic is good sometimes, but bad for documentation
about the API. IMHO, using generic beans are especially difficult when
working with a team because your documentation about the bean's API
isn't built-in and would cause you to document your generic bean's API
(hopefully). Beans are a real slow level objects and basically follow
the same pattern all the time - using a code generator will save you a
lot of hassles.
Best,
.Peter
--
Peter J. Farrell :: Maestro Publishing
http://blog.maestropublishing.com
Rooibos Generator - Version 2.1
Create boilerplate beans and transfer objects for ColdFusion!
http://rooibos.maestropublishing.com/
- Member Team Mach-II
- Member Team Fusion
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]