B
B
beginer1232017-10-24 13:24:24
Programming
beginer123, 2017-10-24 13:24:24

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

5 answer(s)
T
tapokshot, 2017-10-24
@tapokshot

I delete it as soon as I see that it is not used anywhere, you can always restore it using git history.

S
Sergey delphinpro, 2017-10-24
@delphinpro

I noticed such a thing that I leave a lot of code behind, just in case.

Man, start using a version control system, don't be bullshit =)

D
Demian Smith, 2017-10-24
@search

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.

M
Maxim Timofeev, 2017-10-24
@webinar

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

M
Michael, 2017-10-24
@SnowBearRu

Delete the code, maybe not immediately, but clean it with the next revision.
If you want to keep some pieces of code for yourself (according to the how to principle), then use a wiki, for example https://www.dokuwiki.org/DokuWiki or similar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question