知识卡片

普通读书笔记卡 · 1971.o.1.b.4.e

关联规定可遍历行为

理解等级:中级

模型中的可遍历关联,要求软件提供语义一致的查找行为,却不规定必须用对象字段保存指针或集合。原书的经纪账户例子里,getCustomer 和 getInvestments 既可读取内存对象,也可查询数据库后构造对象;两种实现都可符合相同模型。设计仍须写清遍历方向和行为约束,不能只画一条线。示例中的 SQL 工具仅为讲解,原书明确不把它推荐为真实项目方案。参见[[模型驱动设计兼顾分析与实现]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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.