Featured Posts

The concept of Cohesion and Coupling in detail

Cohesion : "It is a natural extension of information hiding concept". Cohesion is a measure of the relative functional strength of a module. The cohesion of a component is a measure of the closeness of the relationships between its components. A cohesive module being performed in other parts of a program.

Figure here

Coupling : "Coupling is measure of interconnection among modules in a software structure." The coupling between two modules indicates the degree of interdependence between them. If two modules interchange large amount of data, then they are highly interdependent. The complexity is basically determined by the number of types of parameters that are interchanged while invoking the functions of the module.

Figure here

Types of Cohesion : The types of cohesion, in order of the worst to the best type, are as follows :

Coincidental Cohesion : Coincidental cohesion is when parts of a module are grouped arbitrarily; the parts have no significant relationship (e.g a module of frequently used function).

Logical Cohesion : Logical cohesion is when parts of a module are grouped because they logically are categorised to do something, even if they are different by nature (e.g grouping all I/O handling routines)

Temporal Cohesion : Temporal cohesion is when parts of a module are grouped by when they are processed - the parts processed at a particular time in program execution (e.g a function which is called after catching an exception which closes open files, creates an error log, and notifies the user).

Procedural Cohesion : Procedural cohesion is when parts of a module are grouped because they always follow a certain sequence of execution (e.g. function which checks file permissions and then opens the file).

Communicational Cohesion : Communicational cohesion is when parts of a module are grouped because they operate on the same data ( e.g. a module which operates on the same record of information).

Functional Cohesion : Functional Cohesion is when parts of a module are grouped because they all contribute to a single well defined task of the module.

Functional
Cohesion

Best
(High)

Sequential
Cohesion

Communicational
Cohesion

Procedural
Cohesion

Temporal
Cohesion

Logical
Cohesion

Coincidental
Cohesion

Worst (low)

The Type of Module Cohesion

Types of Coupling : Different types of coupling are as follows :

Content coupling : Content coupling is when one module modifies or relies on the internal workings of another module. Therefore changing the way the second module produces data will lead to changing the dependent module.

Common coupling : Common coupling is when two modules share the same global data. Changing the shared resource implies changing all the modules using it.