How to Effectively Refactor Legacy Code ?

Raghavan Lakshmana
craftsmanship
Published in
3 min readMar 5, 2019

--

https://zhart.us/refactoring-illustrations/

In the life of a software engineer, substantial amount of time is spent on working with legacy code. A legacy code may require attention either to add a new feature, fix a bug or optimize the application. Michael Feathers in his book Working Effectively with Legacy Code outlines five important steps to improve the efficiency of refactoring legacy code,

  1. Identify the change point
  2. Find the inflection point
  3. Break dependencies
  4. Write tests
  5. Refactor

Assume there exists a car rental system, where any customer can rent a car. For each rental a car will be assigned from the available inventory and a price quote engine would calculate price.

Car Rental Architecture

Now the head of sales comes up with a new requirement to offer prices based on customer start date. So, this legacy car rental application has to be updated to accommodate his request.

Identify the change point

A point at which the change has to be made needs to be identified first. Based on the architecture above, to support the new pricing feature the change has to be made to…

--

--