Working with the legacy code
The term legacy is frequently used, as slang, to describe complex code, which is difficult to understand, is rigid and fragile in nature, and is almost impossible to enhance.
However, the fact is that any code with no automated unit tests is legacy code. A piece of code can be well written. It can also follow coding guidelines, might be easy to understand, can be clean, loosely coupled, and very easy to extend. However, if it doesn't have automated unit tests, then it is legacy code.
Statistically, fixing bugs or adding new features to a legacy project is quite difficult than doing the same to a greenfield project. In legacy code, either automated unit tests do not exist or very few tests are written; the code is not designed for testability.
We inherit legacy code from some other source, maybe from a very old project, from another team that cannot maintain the code, or we acquire it from another company, but it is our duty to improve the quality.
Unit tests give...