D
D
Dos2020-04-11 04:17:02
Problem-Based Design
Dos, 2020-04-11 04:17:02

Interaggregate connections. How to change ID correctly?

I delve deeply into DDD. The issue is related to interaggregate relationships. The first rule of Inter-Aggregate Relationships is that aggregates always refer to each other through a unique identifier (such as a primary key) instead of direct object references. This is understandable, but what if we went a little differently?

For example, there are Events. The event has participants. In the Member Context, we create a Member. ID Generated using the UUID. Some time passes, new functionality is created. Now participants can use their personal accounts. They are registered in the Auth context. There, they also generate this ID. Fine. But now how do we connect these two contexts. Based on the logic, we need to replace the Memer (event participant) ID with the one that was generated in Auth. I could do like this:

1. We add a method to Member changeId(Id $id)
2. We get an ID from Auth and use the method changeId(Id $id)to bind it to an account. Now each Member can have access to his account.

It seems to be simple, but I have a question about the correctness. After all, DDD is a clear language, and the changeId () method is not very clear. And in general, this method is somehow superfluous. Another thing is if the user himself enters the Event and registers as a participant. In this case, we can easily have a connection without any additional methods. By simply assigning an ID from Auth. But how to go from the opposite?) Tell me, please) The question is probably simple, but I want to do it right!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-04-11
@sarapinit

Something wrong. The entity's unique identifier must not change. I would consider creating a Member in one place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question