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
  1. Cover with tests first — characterisation tests that pin current behaviour (even if odd).
  2. Make small steps, run tests after each.
  3. Use IDE refactorings (Rename, Extract Method, Introduce Variable) — they're safe.
  4. Separate refactoring commits from behaviour changes.
  5. For untestable legacy code: find seams (Feathers) — extract an interface around a static/DB call, inject it, then test.
  6. Strangler Fig for big rewrites: route new features to new code, migrate piece by piece.