Where to put the value objects in the domain layer?

architecture, cqrs, domain-driven-design, value-objects

Solution

Each bounded context should implement its own value objects (and entities, of course), even if this leads to code duplication.

As a rule of thumb code reuse across context boundaries should be avoided. There may be exceptions to this rule but using common libraries with domain-related content will quickly interfere with the independent evolution of the affected domain models.

Note: Dan Bergh Johnsson delivered a great and worthwhile talk called The Power of Value - Power Use of Value Objects in Domain Driven Design at Øredev in 2011.

Problem

Knowing that value objects represent a description of the domain, this description can be part of many entities in different bounded contexts. For example the FullName value object, this VO can live in a "book aquisition" context as member of a Customer entity , also it may live in a "book management" context as a member of a BookAuthor entity. Knowing that value objects can be used in different parts of the domain, where should value objects be implemented ? Should they have a special layer/module that every bounded context will be using when needed?

Original source