The Daily WTF
A common anti-pattern is the “expanded conditional”. You know the drill:
if (a == b && b != c) { return true; } else { return false; }
This could be condensed into a single return statement. It’s annoying, and stupid, and frequently part of a WTF, but never a WTF in-and-of-itself.
Except for this one, found by Timo.
// check if the IDs match public bool CheckIfIdMatch(int currentProductId, int foundProductId) { // if the product matches with the target if (currentProductId == foundProductId) { // return true return true; } // else, return false return false; }
This is a perfect block of bad code. It takes a simple task (an equality comparison between integers) and stretches it out to a whole block of code with an expanded conditional. The comments are useless restatements of the code itself. And of course, it’s such a “useful” method, it’s
To read the full article click on the 'post' link at the top.