I have encountered a problem, when I was designing an address and a customer classes (models).
class Customer
(String) first_name
(String) last_name
(String) document_id
(String) phone
(String) email
(Address) contact_address
(Address) billing_address
class Address
(String) street
(String) block
(String) apt
(Location) location
class Location
(String) zip_code
(String) city_name
(State) state
(Country) country
class State
(String) name
(Country) country
class Country
(char[2]) tld
(String) name
But information in State.country doubles with Location.country. However I can't imagine a situation, of not assigning a country to state. Otherwise if I drop country field from Location class, it would be odd to get all locations objects from one country.
Am I missing something?
How about:
class Address2
(String) street
(String) block
(String) apt
(String) zip_code
(String) city_name
(String) state
(String) country
However I will lose additional information about tlds, and I will store duplicated (not optimized) data in Location.state and Location.country