Domain object referenced by two Aggregate roots
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.
精彩评论