Search code examples
entitydomain-driven-designvalue-objects

Multiple addresses as Entity or ValueObject?


I have a registration form for users that can insert multiple addresses. I take User as an entity but I am not sure about collections of addresses. if it was only one address I would take it as ValueObject but I am not sure what about collections of addresses. if I have to take them as ValueObject how can I store them in tables, do I need to define a new table for it, if Yes they get Ids that are wrong for ValueObject.


Solution

  • Collection of addresses is fine as a value object.

    The fact that your storage implementation requires multiple rows (with identifiers?) is an implementation detail of storage that has nothing to do with the model of your domain.