Commented out code
One of my pet peeves is opening a source code file, and seeing half of it commented out, or blocks within it commented out. What’s wrong with this?
Commented out code serves no purpose, other than to confuse.
If you try uncomment it, chances are that the code around it has changed, and the uncommented code now won’t even compile.
Also, when reading the code and trying to understand it, the chunks of commented out code get in the way. “Should I be taking this code into account, or not?”
A lot of the time it is not obvious as to why it is commented out. I’ve seen lots of pieces of code commented out, with no reason given as to why. Maybe the developer was testing something and forgot to uncomment the code before checking in? Or is it old code that was not needed any more (then why is it still here?).
Code is usually commented out when the developer is not sure if the code will be needed in the future, and is leaving it there “just in case”.
Ultimately, you don’t need to keep commented code around. Your source control system can handle it. As long as you comment your commit properly, its a matter of 5 minutes work to find the old code and resurrect it.