Implementing Domain-Driven Design vs Working Effectively with Legacy Code

May 10, 2026 · View on GitHub

Status: reviewed Research basis: mini-only

Verdict: ✅ Complementary

Conflict: 12% Overlap: 38% Complementarity: 78%

Loading Decision

Use together when changing existing code: one rule set controls safe change sequencing while the other defines the target design, construction, architecture, data, or production quality.

Book A Pressure

  • Implementing Domain-Driven Design should drive tasks where DDD implementation choices around contexts, aggregates, repositories, events, services, and translations dominate.
  • Evidence: implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 3-5: applies when DDD implementation choices affect contexts, language, aggregates, repositories, events, application services, package structure, or cross-context integration.

Book B Pressure

  • Working Effectively with Legacy Code should drive tasks where unclear or weakly tested code requires characterization, seams, dependency breaking, and small safe changes.
  • Evidence: working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 3-5: applies when code is expensive to change safely because behavior is unclear, tests are weak, dependencies hidden, or runtime/framework setup blocks feedback.

Complementary Forces

  • Claim: Implementing Domain-Driven Design contributes implementation-level DDD pressure around contexts, aggregates, repositories, events, services, and translation; Working Effectively with Legacy Code contributes characterization, seam, dependency-breaking, small-change, and local-refactoring pressure. Together they are useful only where both scopes are active.
  • Evidence:
    • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 13-31: requires context-first interpretation, consistent local language, Core Domain protection, explicit context interactions and translations, small invariant-driven Aggregates with identity references, Entities/Value Objects/Domain Services/Repositories/Domain Events/Event Sourcing/Application Services by rule, Bounded Context modules, DTO/projection/query separation, CQRS where justified, model-walk code generation, and direct domain/boundary tests.
    • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 13-27: requires treating untested areas as legacy, stating behavior delta and preserved behavior, following the legacy loop, focused tests, effect tracing, smallest useful seam, deliberate dependency breaking, separated behavior/refactor/cleanup, sprout/wrap/extract moves for risky edits, side-effect/policy separation, barrier-specific dependency breaking, responsibility sketching, legacy-risk review, rejecting hidden-dependency expansion or premature architecture, and leaving touched area more testable/changeable.

Overlap

  • Claim: They overlap where both affect safe existing-code change, tests, behavior preservation, ownership, and stopping before speculative cleanup; the overlap score reflects how often an agent would receive similar pressure from both.
  • Evidence:
    • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 48-57: checks explicit context, consistent local terms, protected Core Domain, visible translations, small invariant-driven Aggregates, behavior-bearing Entities/Value Objects, aggregate-root repositories, meaningful events/event sourcing only when right, coordinating application services, and external representations outside the domain.
    • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 42-50: checks legacy risk, behavior delta/preservation, characterization, close fast tests, smallest seam, reduced blocking dependency, separated behavior/refactor/cleanup, cleanup path for temporary seams, and improved understandability/testability.

Conflicts

  • Claim: The tension is scope creep: design or architecture improvements must not override behavior preservation, characterization, or the current-smell stop condition.
  • Evidence:
    • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 7-9: corrects renamed CRUD by requiring operational domain modeling inside an explicit context with local language, small invariant boundaries, identity references, and translation.
    • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 7-9: corrects improving design before gaining control by requiring behavior understanding, preservation, smallest useful seam, dependency breaking, requested change, and local testability improvement.

Use Together When

  • Use together when changing weakly tested code toward Implementing Domain-Driven Design goals: first characterize behavior and create the smallest seam, then apply the other rule set inside the controlled change area.

Prefer One When

  • Prefer Working Effectively with Legacy Code when tests are weak or behavior is unclear; prefer the other book only after control, characterization, or seams make the change safe.

Source Basis

  • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 3-5: applies when DDD implementation choices affect contexts, language, aggregates, repositories, events, application services, package structure, or cross-context integration.
  • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 7-9: corrects renamed CRUD by requiring operational domain modeling inside an explicit context with local language, small invariant boundaries, identity references, and translation.
  • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 13-31: requires context-first interpretation, consistent local language, Core Domain protection, explicit context interactions and translations, small invariant-driven Aggregates with identity references, Entities/Value Objects/Domain Services/Repositories/Domain Events/Event Sourcing/Application Services by rule, Bounded Context modules, DTO/projection/query separation, CQRS where justified, model-walk code generation, and direct domain/boundary tests.
  • implementing-domain-driven-design/implementing-domain-driven-design.mini.md lines 48-57: checks explicit context, consistent local terms, protected Core Domain, visible translations, small invariant-driven Aggregates, behavior-bearing Entities/Value Objects, aggregate-root repositories, meaningful events/event sourcing only when right, coordinating application services, and external representations outside the domain.
  • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 3-5: applies when code is expensive to change safely because behavior is unclear, tests are weak, dependencies hidden, or runtime/framework setup blocks feedback.
  • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 7-9: corrects improving design before gaining control by requiring behavior understanding, preservation, smallest useful seam, dependency breaking, requested change, and local testability improvement.
  • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 13-27: requires treating untested areas as legacy, stating behavior delta and preserved behavior, following the legacy loop, focused tests, effect tracing, smallest useful seam, deliberate dependency breaking, separated behavior/refactor/cleanup, sprout/wrap/extract moves for risky edits, side-effect/policy separation, barrier-specific dependency breaking, responsibility sketching, legacy-risk review, rejecting hidden-dependency expansion or premature architecture, and leaving touched area more testable/changeable.
  • working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md lines 42-50: checks legacy risk, behavior delta/preservation, characterization, close fast tests, smallest seam, reduced blocking dependency, separated behavior/refactor/cleanup, cleanup path for temporary seams, and improved understandability/testability.

Review Notes

  • External context was not used as decisive evidence for Implementing Domain-Driven Design vs Working Effectively with Legacy Code; the verdict is based on the cited local mini line ranges.