知识卡片
关联规定可遍历行为
模型中的可遍历关联,要求软件提供语义一致的查找行为,却不规定必须用对象字段保存指针或集合。原书的经纪账户例子里,getCustomer 和 getInvestments 既可读取内存对象,也可查询数据库后构造对象;两种实现都可符合相同模型。设计仍须写清遍历方向和行为约束,不能只画一条线。示例中的 SQL 工具仅为讲解,原书明确不把它推荐为真实项目方案。参见[[模型驱动设计兼顾分析与实现]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第05章|Associations · 查看原书依据
Both of these designs would reflect the same model. The design has to specify a particular traversal mechanism whose behavior is consistent with the association in the model.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第35章《原书第05章|Associations》(源文件:_epub-src/0321125215_ch05lev1sec1.html;图5.3:05fig03.gif)
- 结论依据:原文指出每条可遍历模型关联在软件中须有同性质的机制,随后用字段集合与数据库查询两种经纪账户实现作对照,并注明示例 QueryService 并非真实项目的推荐设计。
- 原始内容:For every traversable association in the model, there is a mechanism in the software with the same properties. ... Both of these designs would reflect the same model. The design has to specify a particular traversal mechanism whose behavior is consistent with the association in the model.