知识卡片

普通读书笔记卡 · 3281.a

通用工具接口会稀释内聚

理解等级:高级

把不相干的便利功能集中到 utils API,看似复用,实际可能使一个业务能力的改动同时要求工具接口跟着改。划分 API 时先看功能是否服务同一业务目的;若跨域工具承担业务规则,变更影响范围会扩大。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      As a counterexample of high cohesion within the case study, imagine if you created a “utils” API that exposed a collection of convenience functions that could be used across all of the conference entities. This could easily lead to a situation where a change in the code behind one API, such as the Attendee API, requires that another utility API also be updated. Unless you

    参考来源

    - 位置:《Mastering API Architecture》第8章《Redesigning Applications to API-Driven Architectures》之《Aim for APIs with High Cohesion》(源文件:_epub-src/OEBPS/ch08.xhtml) - 结论依据:原文以会议系统的 utils API 为反例,说明 Attendee API 改动可能迫使另一接口一起更新。 - 原始内容:As a counterexample of high cohesion within the case study, imagine if you created a “utils” API that exposed a collection of convenience functions that could be used across all of the conference entities. This could easily lead to a situation where a change in the code behind one API, such as the Attendee API, requires that another utility API also be updated. Unless you