1

I have 2 aggregates: Occupation and WorkActivity.

An Occupation can have multiple WorkActivity. A WorkActivity can also belong to many Occupation.

The aggregate is a basic element of transfer of data storage, according to Martin Fowler.

So the WorkActivity can't be a value object of the Occupation because when updating the Occupation, I don't want to update the WorkActivity, but the list of WorkActivity only. I would call it WorkActivities.

And the Occupation needs to know just the content of the WorkActivity, not other information like description, image, etc.

The question is should I store only the ids of the WorkActivity inside the Occupation as a value object, or should I create new WorkActivity value object with just needed information inside Occupation aggregate?

1
  • What is the behavior in these objects? Commented Oct 25, 2021 at 11:22

1 Answer 1

1

The question is should I store only the ids of the WorkActivity inside the Occupation as a value object,

Yes.

or should I create new WorkActivity value object with just needed information inside Occupation aggregate?

If the preferred method of only storing the id results in a measurable performance bottleneck, then you might consider caching some of the contents of WorkActivity within Occupation. But it should be very clear that the actual WorkActivity aggregate is the source of truth and that the values stored within Occupation are there only for performance reasons and that they may be outdated by the time they get used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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