Mario
Mario

Reputation: 13

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

Upvotes: 1

Views: 232

Answers (1)

Philip Fourie
Philip Fourie

Reputation: 116827

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.

Upvotes: 1

Related Questions