Featured

    Featured Posts

The concept of Cohesion and Coupling in detail


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 :

  1. 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).
  2. 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)
  3. 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).
  4. 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).
  5. 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).
  6. 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.
  • External coupling : It occurs when two modules share an externally imposed data format, communication protocol, or device interface.
  • Control coupling :  Control coupling is one module controlling the flow of another, by passing it information on what to do.
  • Data coupling : Data coupling is when modules share data through.
  • Message coupling :  This coupling is the loosest type of coupling. It can be achieved by state decentralization and component communication is done via parameters or message passing.
Best coupling :  Content Coupling
Worst coupling :  Message coupling

Post a Comment

www.CodeNirvana.in

www.posthatke.com. Powered by Blogger.

Google+ Followers

Copyright © www.posthatke.com | Blogger Templates | Designed By posthatke.com