Imagine you build a social network. There are users who can add other users as friends. How do you model this in DDD? Naturally you cannot simply have a list of friends in the <
A User
could have a list of Friend
s. A Friend
could consist of a UserId, FriendType, GroupId, etc.
A User
could also have a list of FriendRequest
s. A FriendRequest
could have a UserId, RequestMessage, RequestStatus etc.
User
, Friend
and FriendRequest
could all be part of the same Aggregate. But there could be some duplication by doing so. Another option would be to have one FriendRequest for both users involved, and each user would have a list of received and sent FriendRequest
IDs.
This is just to give you some ideas because in DDD, your design will depend highly about how your app will work, and which features are needed. ;-)