I am starting a series of quick tips that I hope to publish weekly. These are intended to be very short posts giving you some quick advice.
Commented out code
First of all, don’t do it. If you have a bit of dead code, delete it. If you are using source control (and you should…I’ll have a post about that later), you can always go back in time and get that code back.
If you find some commented out code, delete it.
Commented out code is dead code. It does nothing for the program, and is harmful to developers. It only serves to clutter the file and make it harder to read the code. Or, even worse, it tempts other developers to reuse that code for other things (that it may not have originally been intended for).
If you need that functionality again, I suggest rewriting it. We are all getting better (or should be) as we continue our careers, so you can probably write it better the second time anyway.