Responsibilities of ApplicationServices versus DomainServices

Wim van Gool <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <CAKqMafx7FqWrjdH2J790so8bf03nZEcEbbK0G0eiLZiQ-TB2Ww@mail.gmail.com>
Everybody knows ApplicationServices and DomainServices are different and
have different responsibilities. Yet, I think it would be convenient to
have a clear list of what things should typically be handled by each
service-type and what not. I'll kick it off by my own thoughts on the
matter and hope others will correct me or help me complete the list (or add
some open questions).

*ApplicationServices* (aka MessageHandlers)
- Live in the ApplicationLayer.
- Know about and handle messages of any kind (commands and events, external
and internal)
- Never contain any business logic, but delegate to the domain(services)
for this.
- Translates message-property values to Domain-instances where required.
- May have some form of exception-handling to handle/convert exceptions
raised by the domain.

*DomainServices*
- Live in the DomainLayer
- Know nothing about messages - only plain arguments.
- Primarily used to coordinate several calls to aggregates in one
transaction, which should be a rather scarce case.

*Remaining questions*:
- Which service would you use to implement adding/removing aggregates and
raise the appropriate DomainEvent?
- Which service would you use to send an email or otherwise call external
services?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.