Is it better to comment out unneeded code or delete it?
Posted
by Matt Connolly
on Stack Overflow
See other posts from Stack Overflow
or by Matt Connolly
Published on 2010-06-18T16:07:35Z
Indexed on
2010/06/18
16:13 UTC
Read the original article
Hit count: 280
For web applications under maintenance, assuming you have source control, when you need to remove part of the UI and the associated code, do you delete the code and check in, or do you comment out the old code?
Arguments in favor of deleting: cleaner code, can still see deleted code in source control history, no worrying about refactoring code that might be uncommented some day.
Arguments in favor of commenting: sometimes you need to add the feature back in and the developer adding it back in may not know to check source control history, sometimes the code represents unique functionality that can be a handy reference, seeing it all in one place can help provide clues to deciphering the active code.
© Stack Overflow or respective owner