Question

When I take a look at our office, some entities and value objects immediately come to my mind.

E.g., an empty post-it from a block of post-its is for sure a value object, as it can not be distinguished from any other empty post-it on the same block, and I don't really care at all about which post-it I use if I need an empty one.

In contrast, me and my co-workers are for sure entities, because each of us has an identity.

A table might be an entity or a value object, depending on the way you look at it (is it just any table quite as good as any other, or is it your table?).

Of course, YMMV.

So, now that I've found some real-world analogies to entities and value objects - what would be an analogy for an aggregate? Is there one?

I could imagine that getting the idea of what an aggregate is in reality helps to understand the concept behind it.

Any suggestions?

Was it helpful?

Solution

Example in blue book:A car.

A car (entity, identified by vehicle identification number) have 4 wheels (entity, identified by left front, left rear , right front, right rear).

I dont need to (and want to) know how the wheels works when I drive a car. The car entity encapsulates them for me as an aggregate root.

Another example in blue book: A purchase order.

At any time, the total amount of sub-purchase orders(local entity) can not be greater than the limit of the purcahse order(aggregate root in this case). The aggregate root should check constraints all the time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top