知识卡片
高内聚API隔离内部变化
内聚是系统元素围绕同一职责归属的程度。高内聚 API 让提供方可更换算法、代码或数据存储,只需守住兼容的外部契约;使用方也更容易理解依赖。接口粒度应贴合真实业务任务,避免为假设的未来暴露过多旋钮。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
Cohesion refers to the degree to which the elements inside a system belong together. Implementing APIs and systems with high cohesion enables the easier evolution of both the API provider and consumer. As a provider, you can alter the internals of your service, such as changing algorithms, refactoring code to improve performance, or changing datastores, and you only have to avoid modifying the external interface
参考来源
- 位置:《Mastering API Architecture》第8章《Redesigning Applications to API-Driven Architectures》之《Creating Useful Abstractions: Increasing Cohesion》(源文件:_epub-src/OEBPS/ch08.xhtml)
- 结论依据:原文定义内聚,并分别说明提供方和使用方因稳定接口获得的演进空间,随后以车辆控制面类比抽象粒度。
- 原始内容:Cohesion refers to the degree to which the elements inside a system belong together. Implementing APIs and systems with high cohesion enables the easier evolution of both the API provider and consumer. As a provider, you can alter the internals of your service, such as changing algorithms, refactoring code to improve performance, or changing datastores, and you only have to avoid modifying the external interface