何时使用域事件与双重调度
我对何时使用域事件以及何时使用双重调度感到困惑。 Udi鼓励我们使用领域事件来维护模型的封装性并远离贫血设计,但在我看来,领域事件只能在操作执行或突然结束后使用,而不是在操作正在进行时使用。
例如:在解决一些业务逻辑时,我需要访问存储库,然后根据值,我可以引发域事件。但问题是模型在解决业务逻辑时如何访问存储库,这里我认为我们可以使用双重调度。
请告诉我,上述说法是否有效?
I am confused with when to use domain events and when to use double dispatch. Udi encourages us to use domain events to maintain encapsulation of model and away from anemic design, but in my opinion domain events can only be used after the operation has been performed or ended abruptly, not at the time when the operation is in progress.
For example: while solving some business logic I need to access the repository, and then based on the value, I can raise domain events. But the question is how the model can access repository at the time of solving business logic, here in my opinion we could use double dispatch.
Please tell me, are the above statements are valid or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多 谈论这个。
我个人同意 Szymon Pobiega 的观点:
您的聚合根应该包含执行操作所需的所有内容。在做某事时不应该需要存储库。聚合根划定了事务边界。
There's been quite much talking about this.
I personally aggree with Szymon Pobiega:
Your aggregate root should contain everything You need to perform operation. There shouldn't be a need for repository while doing something. Aggregate root draws transactional boundaries.