Best Practice of Working with Legacy Code


When you want to make change to legacy code, here some algorithm you can use:

  1. Identify change points.
  2. Find test points.
  3. Break dependencies.
  4. Write test.
  5. Make test
  6. Make change, refactor

The day-to-day goal in legacy code is to make changes, but not just any changes. We want to make functional changes that deliver value while bringing more of the system under test. At the end of each programming episode, we should be able to point not only to code that provides some new feature, but also its tests. Over time, tested areas of the code base surface like islands rising out of the ocean. Work in these islands becomes much easier. Over time, the islands become large landmasses. Eventually, you’ll be able to work in continents of test-covered code.