Search code examples
domain-driven-designspecification-pattern

DDD Specification pattern - where do they belong?


I have an array of Users and I need to know if the array contains only one User and if so, is that User a super user. For this, I think a Specification (isSatisifedBy) is perfect for this, however, where in my application should I save these files? in the bounded context under a Specification folder?

Thanks in advance


Solution

  • See this example made by Eric Evans in his famous book on DDD.

    A specification is part of the domain model, so there should live in the same package of the model, so of course in the same bounded context.
    In this example, Cargo is the model and RouteSpecification is one of its specification.