Code review amusement
I have recently fixed up some code from another developer. There were a few things in the code that I got a little chuckle about. The weird thing is that I have seen these coding behaviors in a few jobs that I have had.
First one that I have to laugh about (to avoid crying) is when developers comment out code blocks, then put a modified version of that code block below the commented version. Maybe this isn’t a bad idea, but seriously, if you are using a source control system then what is the point? Isn’t that what version control is all about? You can look at older versions of the same file, and usually, you can even compare the files to see what was changed.
The second one is when I come across code that basically says if true, do something, if false, then do something, else do something else. How is the else statement ever going to get hit? I’m all for defensive coding, but is this going too far?
I came across a third one last week, but I think I’ll keep that gem to myself.