知识卡片
按需投影缩小契约
消费方只需Profile中的姓名时,应只约定身份到姓名的映射,而非为未来可能需求带上地址和国家等全部字段。书中以GraphQL的不同Profile视图解释按需投影,以REST资源可增添引擎信息而不破坏座位查询解释宽松演进。核心是保留消费者必需的语义,而不是按传输格式认定天然解耦;已依赖字段的含义变化仍需要协调。
这能缓解[[印记耦合扩大变更半径]]中无关字段造成的偶然依赖。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
- · 第13章 契约
原书出处 · 1 处
- 契约 · 查看原书依据
In this scenario, the Customer Wishlist doesn’t have internal access to the customer’s name, only a unique identifier. Thus, it needs access to a Customer Profile that maps the identifier to the customer name. The Customer Profile, on the other hand, includes a large amount of information about the customer in addition to the name. As far as Wishlist is concerned, the only interesting thing in Profile is the name.
参考来源
- 位置:《Software Architecture The Hard Parts Modern Trade-Off Analyses for Distributed Architectures (Neal Ford, Mark Richards, Pramod Sadalage etc.)》第13章《Chapter 13. Contracts》(来源项目:book-sources;源文件:extracted/Software Architecture The Hard Parts Modern Trade-Off Analyses for Distributed Architectures (Neal Ford, Mark Richards, Pramod Sadalage etc.)/_epub-src/OEBPS/ch13.xhtml)
- 结论依据:原文的定义、示例或失败路径支持以下归纳:消费方只需Profile中的姓名时,应只约定身份到姓名的映射,而非为未来可能需求带上地址和国家等全部字段。 其他条件结合本章同小节说明;不将模式目标当成已有运行保证。
- 原始内容:In this scenario, the Customer Wishlist doesn’t have internal access to the customer’s name, only a unique identifier. Thus, it needs access to a Customer Profile that maps the identifier to the customer name. The Customer Profile, on the other hand, includes a large amount of information about the customer in addition to the name. As far as Wishlist is concerned, the only interesting thing in Profile is the name.