知识卡片
客户角色限定货物关联
同一货物可关联多个客户,但各客户承担发货人、收货人、付款人等不同角色。原书模型规定每件货物的每个角色至多由一个客户承担,因此用 Role 限定 Cargo 到 Customer 的关联,而非含糊的多对多连接。角色可先实现为字符串;若有独立行为,再考虑对象。这个基数与表示选择属于原书货运教学模型的假设,不能直接套用到所有业务。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第07章|Introducing the Cargo Shipping System · 查看原书依据
A role distinguishes the different parts played by Customers in a shipment. One is the "shipper," one the "receiver," one the "payer," and so on. Because only one Customer can play a given role for a particular Cargo, the association becomes a qualified many-to-one instead of many-to-many.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第49章《原书第07章|Introducing the Cargo Shipping System》(源文件:_epub-src/0321125215_ch07lev1sec1.html;图7.1)
- 结论依据:原文列举客户在货物中的多个角色,规定同一货物一个角色只由一个客户扮演,并说明限定关联与字符串/类的实现选择。
- 原始内容:A role distinguishes the different parts played by Customers in a shipment. One is the "shipper," one the "receiver," one the "payer," and so on. Because only one Customer can play a given role for a particular Cargo , the association becomes a qualified many-to-one instead of many-to-many.