liveBook · Manning

Refactoring

As explained in Software Architecture Decision-Making

Refactoring is the disciplined restructuring of existing code without changing its externally observable behavior.

Refactoring keeps future change cheap without turning present work into an excuse for architectural overreach. The safest move is often the smallest change that solves the problem without disturbing unrelated code. section 3.1

Use refactoring to preserve practical paths for likely change:

  • Keep ownership boundaries clear and separate business logic from infrastructure code. section 3.1
  • Isolate external integrations behind simple interfaces when replacement or growth is plausible. section 3.1
  • Apply the scout rule, but avoid mixing cleanup with unrelated work because review and judgment become harder. section 3.1
Table 3.2 Responding to perfection drift
Signal
Diagnostic question
Better response
Over-engineering early
What current problem does this complexity solve?
Remove or defer the part that solves only a hypothetical problem. Keep only the structure needed for the known problem.
Designing for hypothetical future scenarios
What evidence suggests this future is likely soon?
Preserve a seam or decision record but avoid building the full future capability until the signal becomes real.
Building abstractions “just in case”
How many real variations exist today?
Wait until there are at least two or three concrete cases, unless reversal would be very expensive later.
Introducing patterns the team cannot maintain
Can the team operate, debug, and evolve this pattern without external heroes?
Choose a simpler pattern now and define the conditions that would justify moving to the more advanced one later.
Treating architecture as a personal project
Who else needs to understand, support, and change this design?
Bring the team into the decision and make ownership, trade-offs, and support expectations explicit.
Optimizing for an ideal end state instead of current value
What value is delayed by pursuing the ideal version now?
Deliver a focused slice first, then strengthen the architecture as real feedback appears.

Use the perfection-drift table to distinguish necessary simplification from premature abstractions, hypothetical capabilities, and patterns the team cannot maintain. section 3.1

How Software Architecture Decision-Making covers it

How deep it goes
Defines deliberate cleanup, minimal change, and the scout rule, but stops short of procedural refactoring mechanics.
Examples
Contrasts hard-coded assumptions, separated business logic, isolated integrations, and cleanup mixed with unrelated work.
What you can do after
Apply it by preserving likely paths for change while deferring abstractions that solve only hypothetical problems.
How it connects
Links refactoring to architecture, code cleanup, ownership boundaries, business logic, infrastructure code, and external integrations.

Also explained in

Compare how 29 books explain refactoring →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Architecture Decision-Making. The section links point to the parts of the book it draws on.