At the Milwaukee PHP Meetup, Arlen Walker talked about how to deal with legacy code. When you write code, you have to manage legacy code. Legacy code can be defined as code that “you don’t understand the code and you have to maintain it”. For more definitions, check out StackExchange discussion on when is code code.
What are your choices?
You could rewrite the code from scratch. Rewriting the code takes time. Time that you may not have. Or you could make the worst part a little bit better. Look at the code and determine what is the worst part about it and improve that piece.
Use code smells to determine where the trouble spots are. You may find problems like long argument lists, long methods, large classes and complex code.
Remember: If you don’t have tests, you have legacy code.
For more details, read Arlen’s slides to learn about managing legacy code: