知识卡片

普通读书笔记卡 · 2123.a

内聚性帮助判断模块边界

理解等级:中级

内聚性描述模块内部各部分为何应放在一起。若拆开后仍必须频繁跨模块调用才能完成一个职责,拆分可能降低可读性并增加耦合。

原书把内聚从功能、顺序、通信、过程、时间、逻辑到偶然分成多种情形;“同一个文件”只是偶然聚合的弱理由。客户维护与订单维护是否分开没有固定答案:要看订单行为是否继续增长,以及分开后需要多少客户知识。内聚判断包含语义和未来变化,不能只凭命名。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Modularity · 查看原书依据

      Cohesion refers to the extent to which a module’s parts should be contained within the same module. In other words, it measures how related the parts are to one another. An ideal cohesive module is one where all parts are packaged together; breaking them into smaller pieces would require coupling the parts together via calls between modules to achieve useful results.

    参考来源

    - 位置:《Fundamentals of Software Architecture》第05章《Modularity》(源文件:`OEBPS/ch03.html`,Cohesion) - 结论依据:原文给出内聚定义、分类和客户/订单维护的拆分问答;最后关于语义与变化的边界是对问答的归纳。 - 原始内容:Cohesion refers to the extent to which a module’s parts should be contained within the same module. In other words, it measures how related the parts are to one another. An ideal cohesive module is one where all parts are packaged together; breaking them into smaller pieces would require coupling the parts together via calls between modules to achieve useful results.