Skip to main content

I have an Addressaddress as part of my domain. AddressThe address keeps information about Countrycountry, Citycity, ZipCodezipcode, Streetstreet and HouseNumberhousenumber. It is used in multiple places - Companya company can have an office Addressaddress, invoicing Addressaddress and/or correspondence Address; Transport has Addresses asaddress; transports have addresses at start, middle and end points; couple of other places, too.

I'm wanderingwondering how to correctly handle this DDD-way. Should Addressaddress be a Value Objectvalue object, an Entity,entity or an Aggregate Rootaggregate root? I've seen similar questions but not surprisingly none of those corresponded well with my domain.

AddressAn address doesn't know how to validate itself - company's Addressesaddresses can be initially almost empty and filled later, but transport's Addressesaddresses should be always complete. So generally it depends on the object containing an Addressaddress, not on the Addressaddress itself.

Next thing is that Addressaddress of one Companycompany is completely independent from Addressesaddresses in other Companiescompanies - event if they are the same in terms of location. Also, changing company's Addressaddress doesn't mean replacing it with another - it is just an update done to the current object. It also doesn't affect other any other Addressaddress. Does that alone qualify Addressaddress as an entity?

As Addressaddress can't function on it's own, it shouldn't be AG, right?

Maybe Addressaddress should be just an interface with CompanyAddress, TransportAddress etc. implementing it? They are following different rules after all...

I'd really appreciate your opinion about this. I feel like I'm missing something here, but can't quite figure out what exactly.

I have an Address as part of my domain. Address keeps information about Country, City, ZipCode, Street and HouseNumber. It is used in multiple places - Company can have office Address, invoicing Address and/or correspondence Address; Transport has Addresses as start, middle and end points; couple of other places too.

I'm wandering how to correctly handle this DDD-way. Should Address be a Value Object, an Entity, an Aggregate Root? I've seen similar questions but not surprisingly none of those corresponded well with my domain.

Address doesn't know how to validate itself - company's Addresses can be initially almost empty and filled later, but transport's Addresses should be always complete. So generally it depends on the object containing an Address, not on the Address itself.

Next thing is that Address of one Company is completely independent from Addresses in other Companies - event if they are the same in terms of location. Also, changing company's Address doesn't mean replacing it with another - it is just an update done to current object. It also doesn't affect other any other Address. Does that alone qualify Address as an entity?

As Address can't function on it's own, it shouldn't be AG, right?

Maybe Address should be just an interface with CompanyAddress, TransportAddress etc implementing it? They are following different rules after all...

I'd really appreciate your opinion about this. I feel like I'm missing something here but can't quite figure out what exactly.

I have an address as part of my domain. The address keeps information about country, city, zipcode, street and housenumber. It is used in multiple places - a company can have an office address, invoicing address and/or correspondence address; transports have addresses at start, middle and end points; couple of other places, too.

I'm wondering how to correctly handle this DDD-way. Should address be a value object, an entity or an aggregate root? I've seen similar questions but not surprisingly none of those corresponded well with my domain.

An address doesn't know how to validate itself - company's addresses can be initially almost empty and filled later, but transport's addresses should be always complete. So generally it depends on the object containing an address, not on the address itself.

Next thing is that address of one company is completely independent from addresses in other companies - event if they are the same in terms of location. Also, changing company's address doesn't mean replacing it with another - it is just an update done to the current object. It also doesn't affect other any other address. Does that alone qualify address as an entity?

As address can't function on it's own, it shouldn't be AG, right?

Maybe address should be just an interface with CompanyAddress, TransportAddress etc. implementing it? They are following different rules after all...

I'd really appreciate your opinion about this. I feel like I'm missing something here, but can't quite figure out what exactly.

Source Link
webfreak
  • 29
  • 1
  • 3

Domain driven design - Address entity / value

I have an Address as part of my domain. Address keeps information about Country, City, ZipCode, Street and HouseNumber. It is used in multiple places - Company can have office Address, invoicing Address and/or correspondence Address; Transport has Addresses as start, middle and end points; couple of other places too.

I'm wandering how to correctly handle this DDD-way. Should Address be a Value Object, an Entity, an Aggregate Root? I've seen similar questions but not surprisingly none of those corresponded well with my domain.

Address doesn't know how to validate itself - company's Addresses can be initially almost empty and filled later, but transport's Addresses should be always complete. So generally it depends on the object containing an Address, not on the Address itself.

Next thing is that Address of one Company is completely independent from Addresses in other Companies - event if they are the same in terms of location. Also, changing company's Address doesn't mean replacing it with another - it is just an update done to current object. It also doesn't affect other any other Address. Does that alone qualify Address as an entity?

As Address can't function on it's own, it shouldn't be AG, right?

Maybe Address should be just an interface with CompanyAddress, TransportAddress etc implementing it? They are following different rules after all...

I'd really appreciate your opinion about this. I feel like I'm missing something here but can't quite figure out what exactly.