Cohesion and Decoupling, what do they represent?

前端 未结 5 1860
广开言路
广开言路 2021-01-30 01:28

What are Cohesion and Decoupling? I found information about coupling but not about decoupling.

5条回答
  •  粉色の甜心
    2021-01-30 01:33

    Cohesion - related to the principle that a class/method should be responsible for one thing only i.e there are no stray methods that don't belong in the encapsulation; a method only does one thing. High/Low cohesion is the degree to which this holds.

    Coupling - how interdependent different parts of the system are. e.g how and where there are dependencies. If two classes make calls to methods of each other then they are tightly coupled, as changing one would mean having to change the other. Decoupling is the process of making something that was tightly coupled less so, or not at all.

    Flexible systems have High Cohesion and Loose Coupling.

提交回复
热议问题