2

Forgive me if this is a truly naive question, I can't find an answer anywhere (which makes me think it is maybe silly and naive).

If I am to hold a reference to an aggregate inside another, I of course use the Uuid of that other aggregate. My question is how should I instantiate that object?

Being that it is a value object of sorts, is it ok to simply call new MyAggId()? I am worried that this means that my two aggregates are now coupled as one uses an object from another one.

Am I over-worrying here and being silly?

2 Answers 2

1

Being that it is a value object of sorts, is it ok to simply call new MyAggId()? I am worried that this means that my two aggregates are now coupled as one uses an object from another one.

The aggregate is already coupled, with or without using the MyAggId type.

  • Using the proper type for it means to reflect that fact in code.
  • Using a "more primitive" type means to hide that fact - intentionally or not.

The problem domain is governing whether two things are coupled or not. The code will mirror the dependency in some way or another.

0

One aggregate can hold a reference to another aggregate without UUID's being involved.

If they are involved the UUID should have been created when the entity was created. UUID's are used when a unique identifying number is needed but creation is distributed so they can't be sure which numbers are new. UUID's are highly likely to be new so long as you keep the number of them reasonable.

Once the UUID has been created with the entity the UUID can be used by anything to uniquely identify the entity.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.