知识卡片
LCOM只揭示结构性低内聚
LCOM(方法缺乏内聚度)通过方法是否共享字段,发现一个类里可能存在互不相关的方法群。原书图3-1中,X 的方法通过字段连成整体,Y 的方法各只接一个字段,Z 有一组可考虑拆出;后两者提示潜在重构点。
LCOM只观察结构关联,无法判定业务语义上应否同属一类。因此高分适合触发回读和讨论,不能自动决定拆类;共享工具类迁移时尤其值得检查。与[[内聚性帮助判断模块边界]]互补。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Modularity · 查看原书依据
All this metric can find is structural lack of cohesion; it has no way to determine if particular pieces fit together logically.
参考来源
- 位置:《Fundamentals of Software Architecture》第05章《Modularity》(源文件:`OEBPS/ch03.html`,Cohesion,图3-1)
- 结论依据:原文说明 LCOM 以字段共享暴露结构性低内聚,并明确不能识别逻辑上的归属;X/Y/Z解释来自图3-1及正文。
- 原始内容:All this metric can find is structural lack of cohesion; it has no way to determine if particular pieces fit together logically.