DDD/NHibernate Use of Aggregate root and impact on web design - ex. Editing children of aggregate ro

Posted by pbrophy on Stack Overflow See other posts from Stack Overflow or by pbrophy
Published on 2009-11-21T04:22:50Z Indexed on 2010/04/01 6:33 UTC
Read the original article Hit count: 811

Filed under:
|
|

Hopefully, this fictitious example will illustrate my problem:

Suppose you are writing a system which tracks complaints for a software product, as well as many other attributes about the product. In this case the SoftwareProduct is our aggregate root and Complaints are entities that only can exist as a child of the product. In other words, if the software product is removed from the system, so shall the complaints.

In the system, there is a dashboard like web page which displays many different aspects of a single SoftwareProduct. One section in the dashboard, displays a list of Complaints in a grid like fashion, showing only some very high level information for each complaint. When an admin type user chooses one of these complaints, they are directed to an edit screen which allows them to edit the detail of a single Complaint.

The question is: what is the best way for the edit screen to retrieve the single Complaint, so that it can be displayed for editing purposes? Keep in mind we have already established the SoftwareProduct as an aggregate root, therefore direct access to a Complaint should not be allowed. Also, the system is using NHibernate, so eager loading is an option, but my understanding is that even if a single Complaint is eager loaded via the SoftwareProduct, as soon as the Complaints collection is accessed the rest of the collection is loaded. So, how do you get the single Complaint through the SoftwareProduct without incurring the overhead of loading the entire Complaints collection?

© Stack Overflow or respective owner

Related posts about ddd

Related posts about aggregateroot