[英]Domain Driven Design Application Services
I have a question regarding application services in DDD. 我对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()
: 给定应用程序服务SecurityAppService,它可以在调用其方法
ConfirmRegistration()
包含以下工作流:
The question is the following. 问题如下。 Is the call to AccountingService legal from the SecurityAppService?
从SecurityAppService调用AccountingService是否合法? Or I should include that into the call to the SecurityService?
或者我应该将其包含在对SecurityService的调用中?
You can use CQRS pattern. 您可以使用CQRS模式。
UserManager has Register(User user) method. UserManager具有注册(用户用户)方法。 He will add user and raise the AddUserEvent.
他将添加用户并引发AddUserEvent。 AccountService and EmailService implements EventHandlers and receive User object through EventHandlerArgument.
AccountService和EmailService实现EventHandler并通过EventHandlerArgument接收User对象。
So, SecurityService nothin knows about other services and all of these services are independent. 因此,SecurityService不知道其他服务,所有这些服务都是独立的。
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.
使用DI可以解耦两个实现之间的直接关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.