Roadmap › Clean Code, Testing & Best Practices › Module: Code Smells and Refactoring
Lessons in this course (12)
6. Safe refactoring and legacy code
IntermediateMediumLesson 6 of 12
- Cover with tests first — characterisation tests that pin current behaviour (even if odd).
- Make small steps, run tests after each.
- Use IDE refactorings (Rename, Extract Method, Introduce Variable) — they're safe.
- Separate refactoring commits from behaviour changes.
- For untestable legacy code: find seams (Feathers) — extract an interface around a static/DB call, inject it, then test.
- Strangler Fig for big rewrites: route new features to new code, migrate piece by piece.