Cohesion: A cohesive module performs a single task, requiring little interaction with other components.
Coupling: A Coupling is an indication of the relative interdependence among modules.
Difference 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 Intra – Module Concept.
|
Coupling is Inter -Module Concept.
|
While designing you should strive for high cohesion i.e. a cohesive component/ module focus on a single task
|
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.
|