1

Let's say I have the following entities.

Product, Option, and OptionValue

  • Product can be created without any options.
  • Option must include at least one OptionValue
  • OptionValue can be created without associations.

In this case, can product be an aggregate root?

I was thinking 'Yes', but then..I can't delete Option objects associated with a Product object when I delete the Product object because other Product objects might be associated with Option objects.

If Product is not an aggregate root, what should I call them? Just an aggregate?

  • What behavior is associated with a Product? with an Option? Not everything has to be represented in an AggregateRoot structure. Some things can just be data that you reference from the AR. – Kasey Speakman Oct 13 '15 at 22:03
  • @KaseySpeakman Not much, except adding/removing Options. it's basically dataset. My main question is..I think..can I call it as AR even if it's most likely just a dataset and does not require its children objects to be deleted with it? – Moon Oct 13 '15 at 22:06
  • 1
    You can try to make just about anything an AR, but it's not a helpful abstraction unless behavior is involved. It sounds like these are just reference data which can be maintained via standard CRUD mechanisms. – Kasey Speakman Oct 13 '15 at 22:11
1

When you have the question "What is the Aggregate Root here?"

One useful exercise that I've heard:

  1. Put all your use cases (behaviors) on sticky notes.
  2. Go through the sticky notes and start piling them together where the use cases are related.
  3. Examine each pile and try to come up with a concept for it.
  4. Go through the use cases in the pile and see if each one matches the concept.
  5. Revise as necessary (move notes between piles, update concepts)

We often expect ARs to be the nouns of the sentences we make describing business processes. But sometimes there is an over-arching theme of the use cases (a higher level abstraction) that ends up being the AR, and the aforementioned nouns are sub-objects (entities or value objects or documents) within the AR or even just reference data.

  • Thank you @Kasey Speakman. I will re-think about my use cases related to those mentioned objects. – Moon Oct 13 '15 at 22:34

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.