Code Refactoring

Last week I got an opportunity to refactor code from one of the class which was responsible to remove the individual spending account balance and replacing it with $0.

 

Task: Make the design and process generic to include other functionality at later point of time.

 

We were 3 members in the team and this is how we started and finished the task.

 

  1. Understand the functionality: We started with testing the existing functionality and understood the pre-conditions and post-conditions.
  2. Understand the code: What the responsible class doing and how it is structured.
  3. The ideas: We started with brain storming and listed down the ideas for the possible changes.
  4. Design Principles: We referred SOLID design principles and applied “Single responsibility Principle”  & “Open/Closed Principle”.
  5. Listed down all the bad smells and done changes.
  6. Tested the flow after the changes.

 

Lots of thought process gone through and we were able to finish the task within the specific timeline.

 

 

Reference: Refactoring Improving The Design Of Existing Code  By Martin Fowler

Java Design Patterns By Vaskaran Sarcar

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑