1

Say I have a namespace as follows:

CompanyName.TechnologyName[.Feature][.Design]

Like this: https://github.com/vkhorikov/DddInAction/tree/master/DddInPractice.Logic/Atms

.Design is the AggregateRoot (e.g. BuyingAggregate). This namespace contains all of my Entities and Value Objects.

Say I also introduce a Domain Service, which uses entities and value objects from the BuyingAggregate only. Should this domain service be part of the BuyingAggregate namespace or should it be placed in another namespace?

I believe it should be put in the same namespace, however, I remember reading a question where the consensus was something different and I cannot find the question - hence the reason for my question.

1

I believe your feeling is right. The domain services should sit with the other domain objects in the same name space.

Both in Eric Evan's DDD and Vaughn Vernon's IDDD books, they use module to describe the name space.

Quotes from Eric

Choose Modules that tell the story of the system and contain a cohesive set of concepts. This often yields low coupling Modules... Give Modules names that become part of Ubiquitous language.

Obviously, getting a name space for the domain services does not serve any of the purpose Eric mentioned.

Moreover, Vaughn Vernon uses kitchen drawer and cabinets metaphor. Putting all domain services in a separated module and out of the module where other business objects sit are bad practice. As Vaughn described,

On the other hand, we would probably not organize our kitchen's contents using a mechanical approach, such as placing all sturdy things in one drawer and all things might break in a high cabinet. We wouldn't want to have to remember that our flower vases are kept with our fine teacups just because both are somewhat fragile.

Grouping all domain services and put them in a sub-module which is inside the original module is not bad, but usually people just don't bother.

0

I'm in the practice of putting my Domain Services as close to the calling AR/Entity as possible. So I'd say 'yes, put your Domain Services under the same namespace as your aggregate'.

Sadly though I don't have any hard evidence in the form of articles why this would be the way-to-go. This is my gut feel telling me this is the right approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.