Do you leave historical code commented out in classes that you update?
Posted
by 18Rabbit
on Stack Overflow
See other posts from Stack Overflow
or by 18Rabbit
Published on 2008-09-23T19:54:53Z
Indexed on
2010/06/02
17:14 UTC
Read the original article
Hit count: 125
When you need to obsolete a section of code (say either the business rules changed, or the old system has been reworked to use a new framework or something) do you delete it from the file or do you comment it out and then put in the new functionality? If you comment it out, do you leave a note stating why it was removed and what it was originally intended to do?
I ask mainly because I've done a lot of contract work for different places over the years and sometimes it's like excavating a tomb to find the actual code that is still being used. Why comment it out and leave it in the file if source control has a record of what used to be there? If you comment out a method do you also comment out/delete any methods that were exclusively used by that method?
What do you think the best practices for this should be?
© Stack Overflow or respective owner