Skip to main content

Cohesion and coupling in software

Short answer

Cohesion measures how closely elements within a module are related; high cohesion (functional) is desirable. Coupling measures interdependence between modules; low coupling (data coupling) is desired. Good design aims for high cohesion and low coupling to enhance maintainability and reusability.

Describe cohesion and coupling.

Cohesion

Cohesion is the degree to which the elements inside a single module belong together and perform one well-defined task. High cohesion is desirable, as the module is easy to understand, test and reuse. Levels (low to high): coincidental, logical, temporal, procedural, communicational, sequential, functional (best). Example: a function that only calculates the CRC has functional cohesion; a "utility" function doing unrelated jobs has coincidental cohesion.

Coupling

Coupling is the degree of interdependence between different modules. Low coupling is desirable: a change in one module does not affect others, which makes maintenance and testing simpler. Types (high to low): content, common (global data), control, stamp, and data coupling (best, only needed parameters are passed).

Good design aims for high cohesion and low coupling, which gives modular, maintainable and reusable software.

✓ Answer checked by Claude Sonnet 5.5

All Instrumentation II chapter 9 questions →