I am trying to get a DDD descriptor and feel that I have a pretty good understanding of entities, aggregates, aggregate roots, repositories, and value objects and how to actually represent these concepts in code.
What I'm still struggling with is representing the links (for example, relationships that do not constitute the totality) in real code. Let them say that I have the following two units:
DISCUSSIONGROUP (entity, aggregate root)
+name: string
+ENTRY (entity)
+title: string
+message: string
+timestamp: date
+madeByUser: USER
USER (entity, aggregate root)
+name: string
+email: string
+memberOf: DISCUSSIONGROUP
A user can be a member of a discussion group, but the user object does not belong to the same aggregate. However, there is a connection between the two (link). When you look at the actual code, I would do aggregate relationships like (using C #):
interface IDiscussionGroup {
string Name { get; }
IList<IEntry> { get; }
...
}
Ie using simple C # links. Do you make DDD links (as described above) I in the same way, that is:
interface IUser {
IDiscussionGroup MemberOf { get; }
...
}
- ?