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

更新实体所属的聚合根 #16

Open
snzhaoch opened this issue Feb 1, 2024 · 0 comments
Open

更新实体所属的聚合根 #16

snzhaoch opened this issue Feb 1, 2024 · 0 comments

Comments

@snzhaoch
Copy link

snzhaoch commented Feb 1, 2024

假设这样一个场景:

  1. 聚合根 A 拥有多个实体 B
  2. a1、a2 是实例化后的聚合根,b1~b4 是实例化后的实体
  3. a1 拥有 b1、b2,a2 拥有 b3、b4

如果一个 usercase 要求把 a1 的 b1 和 a2 的 b3 进行交换,如何处理呢?
此时 b1、b3 并没有被删除,而是更换了所属聚合根


在系统初始设计时,可以通过 A、B 都是聚合根的方式,来规避此问题。

但功能是不断演变的,假如一开始为了高内聚把 B 作为 A 的实体,产品提出交换 B 的需求,产品会认为很简单,一个 update 就可以了,但在 DDD 场景下就很复杂。

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