What is the proper etiquette for handling potentially reusable legacy code in large projects?

I was wondering how best to handle this situation. What is the best way to keep the old code in the comment block in case someone decides to add this functionality to the project again, or should this code be removed in order to preserve the source code and read it?

+1


a source to share


2 answers


This is a duplicate, but I don't have time to find duplicates.

This also does not apply to legacy code. All code is legacy code until it is no longer used.



Answer: use source control. What is this for. The text in your source files should be whatever is currently being executed. Nothing more.

+4


a source


As long as you are using source control, I think it is better to remove unused code. Leaving commented code mixed with live code "just in case" can leave the file difficult to maintian. If the rest of the code is under active development, it is possible that the commented code will be quickly left behind. If the zombie code is ever uncommented, it may not work at all, or the resurrected code may cause a difficult-to-detect problem.



I have been working on "do not delete" projects. It was like working in a junkyard. Searching for the code made me cry. Some methods contain more commented code than compiling code. Madness!

+4


a source







All Articles