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.
- Understand the functionality: We started with testing the existing functionality and understood the pre-conditions and post-conditions.
- Understand the code: What the responsible class doing and how it is structured.
- The ideas: We started with brain storming and listed down the ideas for the possible changes.
- Design Principles: We referred SOLID design principles and applied “Single responsibility Principle” & “Open/Closed Principle”.
- Listed down all the bad smells and done changes.
- 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