Coupling and cohesion

前端 未结 6 559
一生所求
一生所求 2020-12-12 10:31

I\'m trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definiti

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 11:13

    One of the best comprehensive discussions of software design concepts related to OO (including these ones) is Bertrand Meyer's Object Oriented Software Construction.

    Regarding 'coupling', he gives his Weak Coupling / Small Interfaces rule as follows:

    If two modules communicate, they should exchange as little information as possible.

    Meyer's material related to cohesion isn't ever boiled down to a single pithy statement, but I think this sentence from Steve McConnell's Code Complete sums it up pretty well:

    Cohesion refers to how closely all the routines in a class or all the code in a routine support a central purpose

提交回复
热议问题