Wednesday, August 27, 2008

What is Cohesion and Coupling?

Cohesion of a single component is the affinity between different units of the module. High cohesion is expected during designing application architecture.

Coupling between components is their degree of mutual interdependence. Low coupling is expected during design application architecture. Low coupling makes components behave as plug-n-play devices.

  • size: Number of connections between routines
  • intimacy: The directness of the connection between routines
  • visibility: The prominence of the connection between routines
  • flexibility: The ease of changing the connections between routines

Following are the types of Cohesion observed during the design phase:

  • Coincidental Cohesion: (Worst) Module elements are unrelated.
  • Logical Cohesion: Elements perform similar activities as selected from outside module.
  • Temporal Cohesion: Operations related only by general time performed (i.e. initialization() or FatalErrorShutdown()).
  • Procedural Cohesion: Elements involved in different but sequential activities, each on different data. This can be divided into several functions as required.
  • Communicational Cohesion : Unrelated operations except need same data or input.
  • Sequential Cohesion : operations on same data in significant order; output from one function is input to next (pipeline).
  • Informational Cohesion: a module performs a number of actions, each with its own entry point, with independent code for each action, all performed on the same data structure.
  • Functional Cohesion: all elements contribute to a single, well-defined task, i.e. a function that performs exactly one operation.

Following are the types of Coupling observed during design phase:

  • Content/Pathological Coupling: (worst) When a module uses/alters data in another .
  • Control Coupling: 2 modules communicating with a control flag (first tells second what to do via flag).
  • Common/Global-data Coupling: 2 modules communicating via global data.
  • Stamp/Data-structure Coupling: Communicating via a data structure passed as a parameter. The data structure holds more information than the recipient needs.
  • Data Coupling: (best) Communicating via parameter passing. The parameters passed are only those that the recipient needs.
  • No data coupling: independent modules.

More information at:


Anonymous said...


Post a Comment