Answer the question
In order to leave comments, you need to log in
What to do with old pieces of code in a project?
I noticed such a thing that I leave a lot of code behind, just in case.
Let's say I rename the old addToCart function to addToCart7777, or comment on the old pieces of code inside the functions.
Suddenly come in handy.
However, I realized that they somehow complicate the readability of the code.
But I can't completely remove it.
remove only what is 100% no longer needed.
I came up with this solution: in a separate file, for example, old.js, old.php, etc., write down all the things that may come in handy.
Good solution? Is this how the senier developers do?
If not, how should it be?
Answer the question
In order to leave comments, you need to log in
I delete it as soon as I see that it is not used anywhere, you can always restore it using git history.
I noticed such a thing that I leave a lot of code behind, just in case.
Kill them with fire. Remove them with Homeric laughter.
But just in general, in huge commercial projects like booking.com, it is not allowed to remove the old code on a whim and on a whim. What are they doing there? At the entrance to the function, a counter is set, which increases by one each time the function is called, and writes this case to the log. It also records when the function was last called. If within three months the function has not been called even once, then it is demolished.
To do this, there is TODO, so as not to forget where you messed up. And 2 versions of the project, in development - this is acceptable, but in production it is necessary only with an empty TODO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question