coupling和cohesion都是依照从好到坏排序的

对于好的software design,应该有较高的cohesion和较低的coupling.

5个coupling:

  • data coupling 共享原子数据
  • stamp coupling 共享简单数据结构(其实只用到了数据结构的一小部分)
  • control coupling 一个给另一个传参数 调用被调用模块的一小部分
  • common coupling 都可能写全局变量
  • content coupling 一个模块间接援用另一个模块

7个cohesion:

  • information cohesion 每个流动(activity)都有独立代码 都在同一个数据结构上操作
  • functional cohesion 模块外面的所有流动都为了同一个task或者function
  • communicational cohesion 模块中两个流动因为某个流程而互相关联 且操作同一个数据结构(e.g. 更新数据库信息并把数据库信息发送到打印机)
  • procedural cohesion 两个流动因为某个流程而互相关联
  • temporal cohesion 流动因为时序而互相关联
  • logical cohesion 模块中的流动是逻辑上而不是性能上相干
  • coincidental cohesion 模块外面有的性能不相干