LVD vs. Domain-Driven Design

Most comparisons in this series end with a winner for some kind of system. This one does not. Domain-driven design and LVD answer different questions, so asking which is better is a bit like asking whether a floor plan beats a set of building codes. You will probably want both, and the useful part is how they fit together.

Two questions, not one

Domain-driven design, from Eric Evans, is a philosophy about putting the domain model at the centre of the work. It gives you bounded contexts, aggregates, a ubiquitous language shared by developers and domain experts, domain events and anti-corruption layers. Its strength is deciding what the pieces of a business problem are and where their edges fall.

LVD says nothing about how to discover those pieces. It addresses what comes after: once you know the concepts, how should the implementation be arranged so that things which change at different speeds do not get tangled? The book calls the two complementary because they operate at different levels of abstraction. The result is a system that is rich in domain knowledge and disciplined in structure.

Where each concept lands

Take a library-lending system as an illustration. Its model has members, copies of books, loans, reservations and overdue fines. Here is how the usual DDD vocabulary maps onto the layers.

  • Entities and value objects such as a loan or a due date belong in Schema, the most stable layer, because the shape of domain data changes least often.
  • Domain services that are pure computation, such as working out a fine from a due date and a return date, belong in Utils.
  • Aggregate behaviour, the operations that change a loan or a reservation as a unit, is orchestrated in Tools.
  • Repository implementations and anti-corruption layers sit in Resources, at the edge where the outside world is translated.
  • Domain events split in two: the event types live in Schema because they are stable contracts, while the logic that emits them lives in Tools, which changes more often.
  • Application services land in Tools or in the API layer, depending on whether they need to know about a protocol.

That event split is worth pausing on. Teams often keep an event's definition and the code that raises it side by side, and then discover that a small change to when it is raised forces every consumer to recompile. Separating the two by rate of change makes the contract stable and leaves the trigger free to evolve.

Each fills the other's gap

DDD gives you guidance LVD lacks: how to draw aggregate boundaries, how to state consistency rules, how to find bounded contexts and relate them to one another. LVD does not tell you how to identify domain concepts, and the book is clear about that.

Going the other way, DDD describes architectural layers of its own, usually named interface, application, domain and infrastructure, but treats them loosely. LVD supplies the precise part: nine named layers, formal dependency rules and a volatility ordering that says where each concept belongs.

A workflow that combines them

The book suggests four moves for a team using both:

  1. Use DDD's strategic patterns to find the bounded contexts.
  2. Inside each context, decompose the implementation into the LVD layers.
  3. Name the components in each layer with the ubiquitous language, so the code reads like the business.
  4. Let LVD's dependency rules guard the structure, so that the layering does not erode.

Chapter 11 also offers projections for the hybrid, but they are illustrative estimates, so I will not quote them. The qualitative point matters more anyway: the domain vocabulary stays alive in the code, and the layers keep it from sprawling.

The takeaway

If you are already practising DDD, you are not being asked to replace it. Keep the strategic design, and use the layers as the place where each tactical building block lives. The book gives the full mapping with worked examples, and this blog has a closer look in mapping DDD onto LVD layers and when to combine LVD with DDD. For where one bounded context ends and the next begins, see bounded contexts with LVD.

What the book covers

  • A table mapping DDD building blocks to the layers that hold them
  • What DDD offers that LVD does not, and the reverse
  • A four-step combined workflow for a single bounded context
  • Where application services land in Tools or the API layer
  • How event types and event emission are split across layers