1
votes

Hi I am trying to do DDD on a simple cluster of classes.

For an example.

I have channels and lenders.

Channels = Channel A, Channel B Lenders = Bank A, Bank B, Bank C

Channel A has got Bank A, B Channel B has got Bank B, C

How would I design my aggregate root in this case?

Should the aggregate id be Bank Specific? or should it be Channel Specific?

In my other aggregates, I would only ever want to know if it is ChannelA-BankA or ChannelB-BankC, aka one unique Id.

The way I see it, I can make Channel the aggregate root entity, or Bank the aggregate root entity, it will not make a difference? They are a 1 to 1 relationship.

Or should I create a top level class to be the root and references Channel and Bank?

Any advice?

1
1 to 1, many to many etc have no place in DDD, these are rdbms mindset artifacts, avoid them. The Domain objects model domain concepts, behaviour and use cases. The language used must be the one used by the domain expert (and not a technical one based on a specific technology). - MikeSW

1 Answers

1
votes

Aggregate design is always going to be tricky and the better you understand the domain the easier it will become. For an outsider to help is rather difficult (or impossible) :)

But do remember that it isn't necessarily a matter of "which one is the aggregate?". In your case it may very well be that both are aggregates and you link them through value objects (VO) or Ids. For instance, you could have Channel with a ChannelLender VO and in those "other" aggregates where you have a Channel/Bank link you could use some other VO and since ChannelLender has been used you would need some name from your Ubiquitous Language (UL) that represents that concept.

Hope that helps ever so slightly.