我在设计地址和客户类(模型)时遇到了问题。设计地址和客户模型
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
但State.country信息与Location.country一倍。 但是我无法想象一个情况,不是指定一个国家来说明。 否则,如果我从位置类中删除国家/地区字段,从一个国家/地区获取所有位置对象将会很奇怪。
我错过了什么吗?
如何:
class Address2
(String) street
(String) block
(String) apt
(String) zip_code
(String) city_name
(String) state
(String) country
不过我会失去约顶级域名的其他信息,我会在Location.state存储重复(未优化)数据和Location.country
为了便于阅读,我省略了上面所有类中的“(Integer)id”字段。 – 2011-05-29 17:25:08
美国的邮政编码和缩写不是州的地方。例子包括哥伦比亚特区,美属萨摩亚,密克罗尼西亚联邦和欧洲武装部队。 USPS分配了65个双字母缩写; 15个“额外”中的大多数实际上是国家。 – 2011-05-29 18:20:54