↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

The key points of Working Effectively with Legacy Code - Change Messy Software Without Breaking It

The post summarizes Michael Feathers’ book as a practical guide for changing legacy code without breaking behavior. Its core advice is to create automated feedback first, because tests make later changes and refactoring safer.

Reading notes
#

  • Add tests before changing existing code, so you can preserve current behavior.
  • When tests are hard to add, change as little code as possible and use minimal, safe refactorings.
  • Identify seams as places where behavior can be altered without changing source code.
  • Break dependencies first, because external services, databases, and complex setup often block testing.
  • Prefer fast tests that do not talk to infrastructure.
  • Characterization tests capture the current behavior of hard-to-understand code and keep it stable during refactoring.
  • Use the Sprout technique to build new tested code elsewhere, then call it from legacy code.
  • Use the Wrap technique when the new logic should happen before or after an existing method call.
  • Scratch refactoring can help you understand opaque code if you revert the changes afterward.
  • Avoid depending directly on library implementations, since those dependencies spread through the codebase and make upgrades harder.
  • The book is presented as still useful because its advice stays relevant for legacy code work.