About this function: org.apache.commons.lang3.BooleanUtils.isFalse(Boolean bool)
and the similar isTrue
, my co-work (less experienced) use it for every boolean in the code. I am trying to convince him that it is not a good practice because make the code confusing. In my POV, it should be used ONLY if the boolean to be tested is a type of non-primitive Boolean
and it can be null
. Actually, even this I think it is unnecessary, because the implementation of this function is simply Boolean.TRUE.equals(bool)
or Boolean.FALSE.equals(bool)
. Anyway, I think it is totally crazy do something like:
boolean isReady = true;
if (BooleanUtils.isTrue(isReady)) {
// ...
}
when you cold simply do
if (isReady) {
// ...
}
or (!isReady)
for the opposite.
His only argument to use this is "it is easy to read". I just can't accept this argument. Am I wrong? What arguments can I use to convince him that no useless code is better than useless code in this case?
Thank you guys.