← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1971.o.1.b.4.d.1.c.1.a.1.a

地址是否为实体取决于业务

理解等级:中级

同一“地址”在不同业务中不必采用同一种对象身份:邮购公司只用它核对付款、投递包裹,通常把地址当值对象;邮政路线若须跟踪区域重划对具体地址的影响,地址可成为实体;电力公司也可把供电目的地建为实体,或让“住所”承载身份、地址仅作其属性。判断关键是要不要持续识别那个对象,而非它在现实中是否有门牌号。参见[[实体身份取决于业务用途]]、[[值对象按描述而非身份理解]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第38章《原书第05章|Is "Address" a V ALUE O BJECT ? Who's Asking?》(源文件:_epub-src/0321125215_ch05lev1sec3_split_001.html) - 结论依据:原文逐一对比邮购、邮政和电力公司的地址模型,并给出把住所建为实体、地址仍为值对象的替代建模方式。 - 原始内容:In software for a mail-order company, an address is needed to confirm the credit card, and to address the parcel. ... In software for the postal service, intended to organize delivery routes, the country could be formed into a hierarchy of regions, cities, postal zones, and blocks, terminating in individual addresses. ... Alternatively, the model could associate utility service with a "dwelling," an ENTITY with an attribute of address.