During code review I discovered many places of our C# code that looks like this:
if(IsValid()) {
return true;
}
else {
return false;
}
<
Distraction
I know it's occurred in my code before and I can trace that back to when I was interrupted or not paying attention while coding (I solely blame SO!)
Ignorance
Not knowing the better way to do it. We take it for granted that all programmers think logically, but that's not the case. Some coders are going purely on patterns of what they've seen before:
If (integerA == integerB) { //do special stuff }
//Given integer equality; boolean equality ought to look the same...
If (isValid() == true ) { //do special stuff }
Momentum
That's how someone has always done it and therefore that's how they continue to do it.