recall

← recall

Refactoring book

Catalog of refactorings + mechanics for applying them safely. The 2nd edition uses JavaScript.

Martin Fowler · 2018 · engineering

Catalog of refactorings + mechanics for applying them safely. The 2nd edition uses JavaScript.

why it matters

Gave the industry vocabulary for transformations that experienced engineers had been doing intuitively. Naming each refactoring (extract method, inline class, replace conditional with polymorphism) makes them communicable and reviewable. The 2nd edition's switch to JS makes it more accessible than the original Java edition.

key ideas

  • Refactoring = behavior-preserving structural change. The behavior-preserving part is what tests guard.
  • The mechanics matter: small steps with tests between, not heroic restructurings
  • Code smells as triggers: feature envy, data clumps, primitive obsession, shotgun surgery, divergent change — recognize the smell, pick the matching refactoring
  • Refactoring is preparatory: before adding a feature, refactor until adding the feature is easy

memorable framings

  • 'For each desired change, make the change easy (warning: this may be hard), then make the easy change.' — Kent Beck

who should read it

Every working engineer. Skim the catalog; deep-read the mechanics chapter.

covers

references: