On Saturday, 09/21/2002 at 03:01 ZE9, Andy Clark <[EMAIL PROTECTED]> wrote:
> >>>The one thing you might immediately question is my use
> >>>of a Boolean object instead of the boolean primitive.
> > I do so question. An integer with static-final mnemonic values is 
probably
> > more efficient, and (I think) no less clear.
> 
> Yuck. ;) Java has a boolean primitive

But as you just pointed out, you can't use it to represent a tristate 
value. You have to switch to a Boolean object, which is not quite a 
primitive.

Doing so gets you into the == versus .equals() game, if anyone is 
incautious about the difference between Boolean(true) and Boolean.TRUE. It 
also buys you some heap churn and performance loss if you aren't 
consistant in using the latter (which, admittedly, can be managed). 

And frankly, I'm not convinced that Boolean.TRUE/FALSE/null is really more 
legible than yourownclass.YES/.NO/.UNKNOWN. The resulting code doesn't 
look a heck of a lot different.

In internal methods/values, Boolean-and-null for a tristate value wouldn't 
bother me. In an API, it feels like an accident waiting to happen. 

______________________________________
Joe Kesselman  / IBM Research

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to