Possible Duplicate:
Make a big deal out of == true?
When I was a young padawan in the world of programming, a person I considered a mentor told me that if statements are more aesthetically pleasing if written in the following way:
if (condition == false) {
doSomething()
}
or
if (condition == true) {
doSomething()
}
I personally found that in the first case it's true, or at least it's easier to read than
if (!condition) {
doSomething()
}
In the "true" case, it's probably an overkill.
So I just use it when I want to test the condition for the "false" case.
Almost all my current coworkers tell me that way is plain wrong.
Does writing the if statements like that have a performance problem? Am I wasting milliseconds on each evaluation by doing it like that?
Sonar reports them as too complex
Can you convince me to not do it anymore? ...or that it's ok to do it like that?