Yes, because that changes the interface, which will break existing
code. You could make it an OPTIONAL parameter that defaults to
'gallons', and be safe, but I don't like the idea of passing in
parameters that dictate behaviour to methods. I much prefer to have a
distinct method for each distinct behaviour, if that makes sense.
To take a different tact, the standard definition of a getter is a
"Zero argument method that returns the value of an object's property",
not a "one argument method that returns the value of an object's
property, based on some dynamic calulation that relies on the passed
argument". So, you no longer really have a vanilla getter. Note,
however, that neither definition precludes you from doing some wholly
internal computation to arive at the returned value; it's the external
dependancy (the passed parameter) that differentiates them.
Subtle points, but enough to make me take the "add methods" route.
cheers,
barneyb
On 8/30/05, John Ottenbacher <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I am trying to transition from procedural development to OO development.
>
> I'm curious, in the example given is there anything 'wrong' with adding a
> parameter to GetGasLeft()? It would have to be optional and default to the
> original unit of measurement so as not to break existing code.
>
> getGasLeft("GALLONS")
> getGasLeft("METERS")
>
> Thanks,
>
> 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]