In software engineering, coupling is the degree of interdependence between software modules and cohesion refers to the degree to which the elements inside a module belong together.
Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. Low coupling is often a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.
Let us compare some of the differences between cohesion and coupling .
COHESION | COUPLING |
Cohesion is the indication of the relationship within module. | Coupling is the indication of the relationships between modules. |
Cohesion shows the module’s relative functional strength. | Coupling shows the relative independence among the modules. |
Cohesion is a degree (quality) to which a component / module focuses on the single thing. | Coupling is a degree to which a component / module is connected to the other modules. |
While designing you should strive for high cohesion i.e. a cohesive component/ module focus on a single task (i.e., single-mindedness) with little interaction with other modules of the system. | While designing you should strive for low coupling i.e. dependency between modules should be less. |
Cohesion is the kind of natural extension of data hiding for example, class having all members visible with a package having default visibility. | Making private fields, private methods and non public classes provides loose coupling. |
Cohesion is Intra – Module Concept. | Coupling is Inter -Module Concept.a |
Comments
Post a Comment