0
KAS89
81d

So In Domain Driven Design, it is okay to have methods in your domain class to load children (lists) on demand? Example: Your aggregate root is Person. Then a person has a list of books that they’ve read. Is it okay to load that list of books by using person.GetBooks(); instead of loading the books when the person is initialized?

Comments
  • 1
    Aggregate roots are compositions. If youre composition has a hierarchy, that's fine. The aggregate root isn't necessarily a query vector, it's an accumulation of the current state of a given domain context.

    The best way to handle a deep/shallow hierarchy scenario would be to eschew "get*" methods and lean into lazy functionality where attempts to access the data begin the retrieval. Makes things more manageable.
  • 0
    @SortOfTested can you give me an example? A simple one maybe?
Add Comment