Refactoring
Before refactoring
Check the test coverage. If not sufficient, add more
Tests should pass before attempting to refactor
Ensure public access points/interfaces are well tested
Depending on the refactoring level, ensure some of the lower level aspects are tested as well
Refactoring techniques
https://refactoring.guru/refactoring/techniques
Abstract
Encapsulate fields
Type checking/ cases => polymorphism
Break-up code
Large method => smaller multiple methods
Large class => smaller classes with limited responsibility
Improve naming and location
Hard constant value => variable with a constant value. Gives a better name and allows searchability
Last updated
Was this helpful?