Coupling and coheshion
Coupling and coheshion
1. Cohesion
Cohesion refers to how closely related and focused the responsibilities of a module (or
class) are. A highly cohesive module performs a single, well-defined task, making it easier to
maintain and reuse.
1. Functional Cohesion – All parts of the module work together to perform a single function.
2. Sequential Cohesion – The output of one part of the module is used as input for another
part.
3. Communicational Cohesion – All parts operate on the same data or contribute to the
same output.
4. Procedural Cohesion – The parts execute in a specific order but are weakly related.
5. Temporal Cohesion – Elements are grouped because they are executed at the same time
(e.g., initialization).
6. Logical Cohesion – Elements perform similar activities but are executed based on a
control flag.
2. Coupling
Coupling refers to the level of dependency between modules. Lower coupling means fewer
dependencies, making the system more modular and maintainable.
1. Content Coupling – One module modifies another module's internal data (worst type).
4. Control Coupling – One module controls another’s flow via flags or switches.
5. Stamp Coupling – Modules share structured data (objects, records) but don’t need all
fields.
6. Data Coupling – Modules share only necessary data through parameters (best type).