2

我有一个名为的聚合根Configuration,它表示为多租户应用程序上的特定配置客户配置的所有选项。由于要配置的选项很多,用户通常遵循一系列步骤(通过向导),然后有时希望部分保存数据以便稍后完成(可能是第二天)。

我熟悉这个Factory概念,其规则之一是如果部分聚合对象不符合不变规则,则不启用它们的创建。

我的问题是如何解决部分对象用例?

4

2 回答 2

2

If you want to prevent an entity being in a incomplete state, and if you are storing that partially-filled entity just for storing the intermediate request (instead of treating it as one entity), will it be a good idea to have a separate entity to represent the "creation request"? It do make sense that creation request (which you can treat that as a factory on another aspect) can be partially filled and persisted, and upon complete, be used to create the actual entity you want.

于 2012-07-10T09:17:31.720 回答
1

阅读您的要求向我表明,仅允许部分数据集存在聚合,因此我没有看到问题?没有不变量说“只有在完成所有步骤后聚合才被认为是有效的”,实际上似乎恰恰相反。

于 2012-07-10T08:08:48.313 回答