且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DDD-聚合中子对象的修改

更新时间:2023-11-20 15:43:04


  1. 这不是***选择,因为

  1. Is not optimal because it allows breaking domain invariant.

会导致代码重复和不必要的方法爆炸。

Will result in code duplication and unnecessary method explosion.

与1相同。使用Value Object不能帮助保持域不变。

Is the same as 1). Using Value Object will not help with maintaining domain invariant.

此选项正是我要使用的选项。在实现之前,我也不会担心潜在的和假设的变化。设计将随着您对领域的了解而发展,并且以后可以随时进行重构。为了将来可能不会发生的某些更改而阻碍现有设计确实没有任何价值。

This option is what I would go with. I would also not worry about potential and hypothetical changes until they materialize. The design will evolve with your understanding of the domain and can always be refactor later. There is really no value in hindering your existing design for the sake of some future changes that may not happen.