1

I'm in a situation that is the following:

Company is an aggregate root and contains a list of contacts (name, phone, ..).

On another aggregate root "Contract" you are able to add something called "Participants". A participant could be a company or a contact from a company.

As far as I know, DDD doesn't allow to hold a reference in this "participation" to the ID of the contact below the company AR.

How is this solved?

1
  • 1
    DDD doesn't have any strict rules about what is "allowed" and what is "not allowed." Use DDD to inform your design decisions, not dictate them. Jun 23 at 18:24
1

It is correct that entities internal to an aggregate only have local identity. This means that multiple instances of the Aggregate can contain entities with the same Id’s. Therefor it’s not possible to reference those entities from outside the Aggregate.

This is easily solved by upgrading the entity to an Aggregate root of its own. This new AR will have a unique identity of its own and can now be referenced by multiple other aggregates.

2
  • If I use a GUID as a local identity in the aggregate root, can I still don't reference it - even it's against the rules of DDD? Since the contacts can be sorted in the UI for a specific company. Meaning I upgrade it to it's own AR, I'm losing the sort functionality?
    – Jesse
    Jun 24 at 0:23
  • Or in other cases, let's say I want to check if the contact already exists in a specific Company when the Contact is an aggregate root - Then my check moves up the the application layer?
    – Jesse
    Jun 24 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.