Question

Eric Evan's DDD book, Cargo Shipping Example, pg. 168:

Location

Two places with the same name are not the same. Latitude and longitude could provide a unique key, but probably not a very practical one, since those measurements are not of interest to most purposes of this system and they would be fairly complicated. More likely, the Location will be part of a geographical model of some kind that will relate places according to shipping lanes and other domain-specific concerns. So an arbitrary, internal, automatically generated identifier will suffice.

Reason why author made Location an entity is because two different places could have the same name. But since it appears that Location is immutable and thus won't change over time, wouldn't it be better if it was instead a Value Object? Thus:

a) Why couldn't we ( instead of automatically generated identifier ) introduce an additional attribute describing an actual charasteristic of a location, which would help distinguish between the two places with the same name? Then we could make Location a VO.

b) Even if we don't introduce an additional attribute describing an actual characteristic of a location, but instead we use an automatically generated identifier, couldn't we still consider Location as a VO, since the fact still remains that it is immutable and that application would work the same even if it tracked several instances representing the same Location?

c) From the quote it seems that author would designate Location as an entity even if instead of automatically generated identifier we'd use latitude and longitude to help distinguish between different locations. Why?

Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top