Coupling 衡量一个模块对另一个模块的依赖程度;cohesion 衡量模块内部各部分的紧密程度。目标:低耦合、高内聚。
两个维度
text
HIGH cohesion → a class does ONE well-defined job, parts relate strongly ✅
LOW coupling → modules interact through small, stable interfaces ✅
低内聚(不好)vs 高内聚(好)
python
:
(): ...
(): ...
(): ...
: ...
: ...
: ...
