Implementation

I like this BusinessPriority example because it demonstrates all of the Value characteristics and more. Besides showing how to design for immutability, conceptual wholeness, replaceability, Value equality, and Side-Effect-Free Behavior, it also demonstrates how you can use a Value type as a Strategy [Gamma et al.] (aka Policy).

Image

As each test method was developed, the team understood more about how a client would use a BusinessPriority, enabling them to implement it to behave as the tests asserted it should. Here is the basic class definition along with constructors that the team coded:

public final ...

Get Implementing Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.