English 中文(简体)
DDD: 根扎根内的地方特征模式
原标题:DDD: Model local identity inside agregate root

after reading the blue book (Eric Evan s Domain Driven Design) and starting applying the DDD concepts in a simple blog like application I have the following question, how do you model a local identity of an entity inside an aggregate root??

Let s say for the sake of simplicity, I have a simple blog model that has the following entities and scenarios: A registered user can publish a post, a post can have one or more tags associated and a registered or unregistered user can publish a comment on a post.

在这种情形下,各实体是用户、邮政和评论,其总根基是用户年员额在员额总汇内进行总体评论。

因此,由于评论实体在邮局内有当地身份,我如何模仿其当地身份? I.E. 我不能仅凭其属性而有所不同,因为我对同一用户公布的同一职位可以有不同的评论,内容相同。

我首先想到该员额评论清单内的意见顺序,以便查明该员额内的意见,但这在同时的环境中变得非常复杂,例如,有两个客户可以就博客发表评论的网络应用,在我存放数据库之前,我会发生碰撞。 除此以外,我还必须保持从存放处恢复评论清单的逻辑,以便把该员额节省到存放处......

然后,在《邮政和自动加固》内有一个独特的识别器,并发表每条评论,但在同时的环境里却变得复杂,因此我如何在整体内模仿当地特性?

Thanks Pablo

最佳回答

良好问题。 https://rads.stackoverflow.com/amzn/click/com/0321125215“rel=“nofollow noreferer”> Eric Evan s book:

ENTITIES inside the boundary have local identity, unique only within the AGGREGATE.

......只有AGGREGATE根基可以直接通过数据库查询获得。 所有其他目标都必须通过协会的招贴画找到。

我认为,第二部分是重要的。 页: 1 评论 Id as local identity. 换言之,你不应绕过Aggregate Fundamental(Post),从外部征求参考意见。 技术性赞扬 象您对用户和邮政(或来自解放国的任何其他排放者)一样,Id也可以是数据库生成的同一个非洲联盟-联合国达尔富尔混合行动。 但从概念上讲,将具有地方特性。 解决该问题的是阿吉特人的工作。

问题回答

我没有DDD专家,但我要说,也许评论应该是一个价值目标。 价值物体没有“接受特性”,但肯定会具有持久性特性。 通常,你更喜欢使用价值物体而不是实体,因为后者通常具有更多的间接费用。

• 将持久性认同与概念特性混为一谈。 我在一开始就对此有疑虑。





相关问题
DDD - Returning entity in response to a service operation

I am new to domain driven development & have a simple question. If a service needs to generate some entity as a response to an operation then how should it be done? One of the ways is to inject ...

Domain Driven Design efforts in dynamic languages? [closed]

Are you aware of any DDD efforts in a dynamic language ? Practical resources on DDD tend to decrease quite dramatically when straying from enterprise-oriented solutions (a google search exluding C#, ....

Accessing domain objects in the view

If I don t want to expose the internal state of my Domain Objects, but I need to display them, I can think of three approaches. Which of these is the most "correct" (if any?). The "DTO/ViewModel ...

DDD screen cast question?

I wathced a screen cast on DDD by Greg Young the other day which spoke about persisting all state transitions of an object, instead of it s state when saved, then to load it "replay" all these ...

How to fluent-map this (using fluent nhibernate)?

I have two tables in my database "Styles" and "BannedStyles". They have a reference via the ItemNo. Now styles can be banned per store. So if style x is banned at store Y then its very possible that ...

热门标签