开发者

Domain object referenced by two Aggregate roots

开发者 https://www.devze.com 2023-01-31 05:22 出处:网络
i have designed a model for a website with the following domain objects: Article <> Event <> (like festival, ...)

i have designed a model for a website with the following domain objects:

Article <> Event <> (like festival, ...) Comment <> (can be created for articles and events)

Where do i put the Comment-Domain Object in the model? Should it stay alone or use it's own aggregate? But a comment makes no sense without an article or an event....

Thanks 开发者_开发百科Mario


Firstly DDD doesn't prevent two aggregate roots to reference the same domain object. As long as the object is not part of both the aggregate root boundaries.

In this case I would consider to create an ArticleComment and EventComment objects, each belonging to their relevant aggregate roots. This should be clearer working with a comment object that only applies to one type being commented on. You can still enforce common data and behaviour by having an abstract Comment class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号