Michael Jablonski

March 18, 2021

Commented-Out Code

Over the years I have accepted contracts to modify existing computer programs to add new features.  In all of them, without exception, I found lots of commented-out code in the source code.  The commented-out code was no help. 
 
Keeping commented-out code is a bad practice.   
 
“Clean Code, A Handbook of Agile Software Craftsmanship,” by Robert C. Martin and others, shows a code snippet with commented-out code and says:
 
“Why are those two lines of code commented?  Are they important? Were they left as reminders for some imminent change? Or are they just cruft that someone commented-out years ago and has simply not bothered to clean up.”
 
“There was a time, back in the sixties, when commenting-out code might have been useful.  But we’ve had good source code control systems for a very long time now.  Those systems will remember the code for us.  We don’t have to comment it out anymore. Just delete the code. We won’t lose it. Promise.”