Note that there are some explanatory texts on larger screens.

plurals
  1. PODealing with nested aggregates in DDD
    primarykey
    data
    text
    <p>I'm just getting started in DDD, and I'm having some trouble figuring out how to accommodate the relational nature of my data. I have what I believe would be considered my aggregate root, but the aggregate also has an aggregate of its own. Not wanting to violate the Law of Demeter, I'm wondering if I'm thinking about this wrong and am hoping that some DDD expert can offer some insight.</p> <p>My aggregate root is my <code>Account</code> object, which has an aggregate of numerous <code>AccountElement</code> entities, which are themselves logical groupings of individual <code>ProductComponent</code> entities.</p> <p>An <code>AccountElement</code> outside of the context of an <code>Account</code> has no meaning, so I'm comfortable with my conclusion that the <code>Account</code> object is my aggregate root, and I anticipate that entity having an aggregate <code>Elements</code> property. It's the <code>ProductComponent</code> collection that has me confused. This aggregate has no meaning outside of an <code>AccountElement</code>, and <em>really</em> has no meaning outside of an <code>Account</code>.</p> <p>I don't think I should be accessing individual <code>ProductComponent</code> objects by dotting my way to it, like:</p> <pre><code>var reference = account.Elements(0).ProductComponents(0).ReferenceCode; </code></pre> <p>But at the same time it doesn't make sense (from a domain perspective) to access a <code>ProductComponent</code> directly from an <code>Account</code> entity.</p> <p>I'm sure that this is all a little difficult to comprehend without knowledge of my domain, but I'm hoping it's enough to get some good feedback.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload