Cohesion and Decoupling, what do they represent?

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

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

5条回答
  •  情歌与酒
    2021-01-30 01:46

    Here are my thoughts on cohesion. Imagine there is a module. Inside that module, we have some tasks. When those tasks are highly related to each other, we say it has high cohesion. When those tasks are not related, we say it has low cohesion. My best attempt to explain decoupling is that decoupling is the act of removing coupling.

    Low Coupling helps us get to high cohesion! Remember that we want our module to have related tasks and one single responsibility. But what is coupling? Coupling is the degree of dependency on other modules to achieve our single responsibility for that module. So by low coupling, we are saying that we are not very dependent on external modules hence we have high cohesion.

    However, if we have many dependencies to external modules, we would have high coupling and low cohesion. Get it?

    Other more decorated thinkers and groups say:

    Cohesion is the degree to which the tasks performed by a single module are functionally related." IEEE, 1983 "Cohesion is the "glue" that holds a module together. It can be thought of as the type of association among the component elements of a module. Generally, one wants the highest level of cohesion possible." Bergland, 1981

    A software component is said to exhibit a high degree of cohesion if the elements in that unit exhibit a high degree of functional relatedness. This means that each element in the program unit should be essential for that unit to achieve its purpose. Sommerville, 1989

提交回复
热议问题