Hi!
to start with: We find fbcontrib very useful, use it a lot and reported some bugs before.
I understand, that people have different opinions about what findbugs/fbcontrib reports are useful and what aren't.
But I don't understand the motivation behind NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION when used on the following code:
void doit(Boolean b) {
...
}
doit(true);
1. The code is short (true instead of Boolean.TRUE)
2. No memory is wasted (javac should autobox to Boolean.TRUE and Boolean.FALSE)
3. Nothing can go wrong (no null pointer risk or such).
I find it useful for situations as
void doit(boolean b) {
}
doit(Boolean.TRUE)
but I think it does not make sense for the first situation.
Thanks for a great program!
Greatings,
alph
Logged In: YES
user_id=66596
Originator: NO
I agree the problem is not that big of a deal. However, in my experience, people often don't pay attention to the boxing level of their variables, and pass them around all over and constantly switch between boxed and unboxed versions for no reason other than not paying attention.
I'm not sure why you would do
void doit(Boolean b) {
...
}
doit(true);
over
void doit(Boolean b) {
...
}
doit(Boolean.TRUE);
even if you consider the extra Boolean.valueOf method call irrelevant.
Logged In: YES
user_id=66596
Originator: NO
I agree the problem is not that big of a deal. However, in my experience, people often don't pay attention to the boxing level of their variables, and pass them around all over and constantly switch between boxed and unboxed versions for no reason other than not paying attention.
I'm not sure why you would do
void doit(Boolean b) {
...
}
doit(true);
over
void doit(Boolean b) {
...
}
doit(Boolean.TRUE);
even if you consider the extra Boolean.valueOf method call irrelevant.
Why? Maybe the caller and the callee are in different packages developed by different people. Just because the API accepts
null
, it doesn't mean I want to emphasize that fact when calling it withtrue
orfalse
. "Be conservative in what you do, be liberal in what you accept from others"Or maybe the function accepts Object, as it's the case with
JSONObject#put()
. Surely I can passBoolean.TRUE
, but then I'm doing another thing needlessy, specifically accessing a public static member ofBoolean
. Between those two "needless" alternatives, I prefer the one that is short and idiomatic.All the rest of the suggestions from fb-contrib are very useful, but this one just doesn't belong with the rest.