Take the 2-minute tour ×

I just started learning about domain driven design, and one of the few things that confuse me the most is how to determine which one should be entity, which one should be value object

I know to determine entity/value object, we need to base on the domain context, in one context, one domain object can be entity, in another, it can be value object, but still there are some situations I can't decide

.e.g. address - In the context of a customer management application (let's just say an application to manage customers, add/delete/change status,etc of customers), address is clearly value object because here we don't need to differentiate between one address from another, 2 customers can have same address - On the other hand, in the context of a online booking application, can I say address is an entity? because now we need to differentiate customers by their billing address (just ignore the case 2 customers having same address for the moment)

To me, address is unique itself, so it definitely already has identity. So identity of a domain object will not decide whether it's an entity or value object, if so then what will be the key factors to choose?

Another example, I have one application that list a number of areas in one country, user can choose one area, and find all the restaurants that fit their searching criteria in that area. In this case, is area a value object or entity? Currently I think it's more on an entity but still not very sure. Each area is unique also

I'm not sure whether my question is clear or not, I try my best to explain my thinking currently

share|improve this question

1 Answer 1

up vote 5 down vote accepted

I think some of your difficulties may be in the subtle meanings of some of these terms. For example, you mention "To me, address is unique itself, so it definitely has identity". In terms of how most people use "identity" in domain-driven design, your statement would probably be incorrect.

A value object's set of attributes is its definition. If you change any aspect of it, you have a completely different object. Using your address example, if you change any part of it, you get a entirely different address. It is not the same address with aspects of it changed. Your customer moved to a new address; they did not change aspects of the same address.

However, if you were a mapping application and the address itself changed, then here, the address would be a entity. In such a scenario, the city planners may want to re-number houses on the street. In that case, the SAME address is being modified. In that case, we would need to update the entity, not a value object.

Regarding your billing address example, the billing address is probably still a value entity (at least the physical address portion of it). A payment method (e.g. credit card) may be the entity in that example, and it may include other value objects (such as billing address, credit card number, etc).

You may find it helpful to see review this question and its answers as well: Value vs Entity objects (Domain Driven Design)

Hope this helps. Good luck!

share|improve this answer
thank you very much, your explanation is what I'm looking for, everything now is clearer –  Phuong Nguyen Mar 19 '12 at 15:42
Thanks, Phuong, glad it helped. –  Chris Melinn Mar 19 '12 at 21:16

Your Answer


