Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Handler VS Application Service VS Domain Service #448

Open
lynndisco opened this issue Sep 4, 2023 · 1 comment
Open

Command Handler VS Application Service VS Domain Service #448

lynndisco opened this issue Sep 4, 2023 · 1 comment

Comments

@lynndisco
Copy link

lynndisco commented Sep 4, 2023

最近一直想理清楚CQRS中的Command Handler和DDD中的Application Service以及Domain Service间的调用关系。有几个问题想探讨一下。

Command Handler VS Application Service

  1. CQRS的概念中Command和Query是程序的两条路径,是不是应该由Command Handler调用Service而不是反过来?目前看来Client中接口的实现类可以算作真正逻辑开始的地方(在COLA里是ServiceImpl而不是Command Handler)
  2. 此外Command作为CommandHandler的入参概念上似乎要比作为Service的入参更合理一点。

Command Handler VS Domain Service

  1. COLA的Sample中只在App层存在一个Service,是否可以理解为就是Application Service?
  2. 如果需要跨聚合根操作多个实体(比如,结算单创建的同时回写订单状态),在COLA架构下是否只能通过Command Handler或者Event Handler来实现(毕竟Sample里的Domain层没有Service)。
  3. 如果我在Domain层创建Domain Service,并由Command Handler调用,就回形成Application Service -> Command Handler -> Domain Service的调用,看起来不是很合理。(我理解应该是,Command Handler -> Application Service(Optional) -> Domain Service(Optional)
@lynndisco
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant