Reputation: 3627
I have a question regarding application services in DDD. For instance, I have a rule that when a user confirms registration the following actions take place:
Given an application service SecurityAppService, can it can contain the following workflow on calling its method ConfirmRegistration()
:
The question is the following. Is the call to AccountingService legal from the SecurityAppService? Or I should include that into the call to the SecurityService?
Upvotes: 4
Views: 392
Reputation: 6465
IMHO, the answer is Yes it is legal. A service is allowed to call another service when it is appropriate. In the particular example, it is definitely something that you want to do. The real question is how you manage the dependency. Use DI so that you can decouple the direct relation between the two implementations.
Upvotes: 2
Reputation: 542
You can use CQRS pattern.
UserManager has Register(User user) method. He will add user and raise the AddUserEvent. AccountService and EmailService implements EventHandlers and receive User object through EventHandlerArgument.
So, SecurityService nothin knows about other services and all of these services are independent.
Upvotes: 3