I'm trying to get a handle on DDD and feel that I've got a pretty good grasp regarding entities, aggregates, aggregate roots, repositories and value objects and how to actually represent these concepts in code.
What I'm still struggling with is how to represent references (i.e relations that don't make up an aggregate) in actual code. Let's say I have the two following aggregates
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 entity don't belong in the same aggregate. There is still however a relation between the two (a reference). When looking at actual code, I would implement aggregate relations such as (using C#):
interface IDiscussionGroup {
string Name { get; }
IList<IEntry> { get; }
...
}
I.e using simple C# references. Would you implement DDD references (as described above) i the same manner, i.e:
interface IUser {
IDiscussionGroup MemberOf { get; }
...
}
of should one use some other construct to indicate the weaker type of relation?