[ajug-members] boolean best?
Tim Watts
timtw at earthlink.net
Fri Dec 12 11:56:19 EST 2008
As Andrew points out the implementation isn't as important at the conceptual
representation. In my experience, a boolean is seldom a good choice to
represent real world things. Internal object state?, yes; real world state?,
not so much. A robust application almost always has to allow for the "Don't
know" factor.
On Friday 12 December 2008 10:25 am, AGoodspeed at cfglife.com wrote:
> The most important thing is not how you implement it, but that it meets
> your requirements. Certain applications may require separate sex and
> gender attributes (and/or multiples for an individual, like birth,
> current...) for example, and either of them can have more than two values
> depending on the requirements.
>
> Also, you can wrap the attribute in as many ways as you need -
> isMale/isFemale, getGender... - and none of them have to directly relate
> to its representation in persistent storage if it is stored. I would
> suggest using the tenet of doing the minimum that will provide the desired
> function. If you have a required attribute that has two fixed possible
> values that you will always know the value for then boolean would be a
> fine representation; if you may not know the value then the object form
> (Boolean) would be better. An enum would be a reasonable approach,
> particularly if you need more than two values. A string would be good if
> it is descriptive rather than discreet values.
>
> Pick a working approach for your requirements and move on.
>
> -Andrew Goodspeed
>
>
>
>
> "521" <521 at ofig.org>
> 12/12/2008 08:51 AM
> Please respond to
> ajug-members at ajug.org
>
>
> To
> ajug-members at ajug.org
> cc
>
> Subject
> [ajug-members] boolean best?
>
>
>
>
>
>
> would boolean be best...:
> an object/class named Living...
> ?have a string gender ("male"/"female") OR have a boolean isMale or
> isFemale?
> which is more efficient (better design/etc.)?
> barclay_______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
--
The secret of life is to appreciate the pleasure of being terribly, terribly
deceived.
-- Oscar Wilde
More information about the ajug-members
mailing list