DDD汇总和值对象 [英] DDD Aggregates and value objects

查看:64
本文介绍了DDD汇总和值对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问有关DDD功能的问题。可以说我们有两个聚合,每个聚合都包含值对象地址。根据埃里克·埃文斯(Eric Evans)DDD,我们应该将集合彼此隔离,因此第一个集合的集合根不能有指向地址的链接。坦白说,这对我来说似乎没有意义,所以问题是如何解决这种情况?哪个聚合应包含地址?

I'd like to ask question about DDD features. Lets say we have two aggregates and each of them contains value-object Address. Accordingly to Eric Evans DDD, we should isolate aggregates from each other, so aggregate root of first aggregate can't have a link to Address. Frankly, it doesn't seem to make sense for me, so question is how to resolve such situation? Which aggregate should contain Address?

谢谢

推荐答案

它使用相同的值对象。但是只有在聚合根存在于相同的有界上下文中并且因此对于两个聚合具有相同的含义时,才执行此操作。如果聚合存在于不同的有界上下文中,则有2个独立的聚合项并重复。

You could have it using the same value object. But only do this if the aggregate roots exist in the same bounded context and hence has the same meaning for both aggregates. If the aggregates exist in different bounded contexts, then have 2 separate ones and duplicate. Leaking one bounded context's concerns into another is what Eric is trying to fight.

在大多数情况下,实体与价值客体的关注归结为人们存在重复性问题。数据。我们已经受过训练,可以思考单个规范模型的第三范式。 DDD通过在需要的地方强制重复并允许曾经被认为是很多的概念来解决不可避免的复杂性。

To most, the concerns of entity vs. value object boil down to people having issues with duplication of data. We have been so trained to think in 3rd normal form of a single canonical model. DDD fights the inevitable complexity that that brings by forcing duplication where it's needed and allowing concepts that were once thought to be one into many.

希望这会有所帮助

这篇关于DDD汇总和值对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆