ArjanCodes
36 minutes
Refactoring legacy code is the disciplined restructuring of existing code, without changing its observable behavior, to make it easier to extend and understand, and it can be organized as a five-step framework: analyze, set goals with a measure of success, build a safety net of tests, refactor in small verified steps, and measure success against the goal. The safety net of tests is the enabling mechanism, since behavior-preserving transformations can only be trusted if a complete set of tests passes after every step. The practice belongs to software engineering and maintenance, and a code kata is a practice exercise used to rehearse the technique.