OO-newb here...

Say you have an object that under the hood is represented as a private
integer property. Each allowed value also has a text representation, and
there's a toString method that returns it, for the object's current internal
numeric value. I've implemented that translation as a simple list of the
text values, which toString indexes into with the numeric value.

Would you think that the definition of that list should be a (static)
private property of the object itself, or just a local var within the
toString method?

As of now, the list is only used by that one method. It's possible that a
setFromString method will be needed later, to set the internal numeric value
based on a passed string from that list.

My gut says it's an object property, whether setFromString exists or not.
Fundamentally, it describes the meaning of each numeric value, regardless of
how many methods that use it happen to actually be needed now. Any future
methods that need this mapping should have access to it, so it belongs to
the object itself. OTOH, if its only use is inside a single method, maybe
it's just an implementation convenience, like a loop counter or something.
It could have been a switch statement, or an array, whatever, it's just how
the code happens to be written.

Obviously, this isn't important from an implementation angle; either
construction will work. Just trying to get my head into doing objectness
right.

Thanks,

Dave Merrill




----------------------------------------------------------
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]


Reply via email to