开发者

Domain Driven Design - Aggregate Question

In a nutshell, my domain allows users to submit stories (about a person or team of people) that contain a multitude of different states and transitions its can be in and what behavior is allowed during those states.

So, at this state in the design, users are creating drafts and submitting their stories. My domain contains Stories, Teams, and Team Members.

My first question is who has the re开发者_如何学运维sponsibility to load the complete aggregate? Should the application layer specify this based on the task at hand? Should he really need to know what all data needs loaded? Or should this belong to the repository that always eager loads the associated data? Maybe use lazy loading (transparency can be a little scary)?

For my next task, I need to allow comments to be added to stories and create records whenever a user views a story. Would this belong to the aggregate since they have no meaning without a story? Here is my confusion. If they do belong to the aggregate, I would have to load the entire aggregate when adding a comment or simply adding a record it has been viewed?

Any help would be great and as you can see, I'm new to DDD.

Thanks!


I'm not sure how this would work in EF, but with NHibernate I would have the application layer load the aggregate root from the repository with lazy-loading enabled (I assume EF has the same lazy-loading capability).

The Comments would be accessed under the aggregate of the Story (again lazy-loading is your friend here).

I would not put the story-views under the story since that sounds like an orthogonal concept to the story itself. I've gotten into trouble before by adding user log-in info (like last log-in time) to the user. It was expedient, but made a mess of my model. Your mileage may vary on that one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜