What if the units in the DB change from gallons to litres? You don't
want getGasLeft so start returning a value 3.8 times larger than
expected.  So you'd deprecate that method, and then add
getGasLeftGallons() and getGasLeftLitres() or something.  You don't
get that protection with instance variables, because as soon as the
switch happens, the instance variable's semantics change, and with no
indication.

Another example is getAge(), because you very likely aren't storing an
'age' variable, but rather than 'dateOfBirth' variable that needs
computation.  But the calling code shouldn't care (or even be able to
tell); that's encapsulation.

Autogenerated get/set methods aren't any more helpful than just
exposing the raw data members.  The encapsulation only comes when
they're actually encapsulating something, usually a conversion from
the publicly exposed properties to the actual internal representation.

cheers,
barneyb

On 8/29/05, John Farrar <[EMAIL PROTECTED]> wrote:
> John,
> 
> OK.. that's fine. But how do we determine that knowing a protected variable
> called car.gas that is read only is any different than a method called
> car.getGasLeft(). It seems to me that they both return the same thing. If
> you don't change one your just as safe as not changing the other. Could you
> (I'm likely a lost cause on this... just hoping to get the point) try to
> clear that up for me? It seems like you could create a getter/setter
> function that sets the return type on variables just like on functions. This
> is something a number of us signed of to the CF Wish list before version
> CFMX7 shipped. We are hoping to see it rise to exist in the next version.
> (I.E. Should I change my vote?)
> 
> John
> 
-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 100 invites.


----------------------------------------------------------
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).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to