There is no right or wrong answer, since it largely depends on the circumstances.
If the code works live, works, is not documented, and does not contain a testing infrastructure, I would not touch it. If someone comes back in the future and wants new functions, I will try to use them in existing code, changing as little as possible.
If the code is faulty, problematic, missing functions, and was written by a programmer who no longer works with the company, I would probably redesign and rewrite all of this. I could always refer to this programmer code for a specific solution to a specific problem, but it would help me reorganize everything in my mind and in the source. In this situation, all this is probably poorly designed, and it can completely rethink.
For everything that was between them, I would stop on your approach. I would start by cleaning everything cosmetically so that I can see what is happening. Then I would start working on what code stood out, since it needed to work the most. I would add documentation as I understand how it works, so that I can help remember what is happening.
Ultimately, remember that if you are going to maintain code now, this should be in accordance with your standards. Where this is not the case, you should take the time to bring it to your standards - no matter what it costs. This will save you a lot of time, effort and frustration in the future.
Errick robertson
source share