cohesion – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Mon, 05 Oct 2020 16:13:53 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg cohesion – Programmerbay https://programmerbay.com 32 32 Difference between Cohesion and Coupling https://programmerbay.com/difference-between-cohesion-and-coupling/ https://programmerbay.com/difference-between-cohesion-and-coupling/#respond Sun, 03 May 2020 09:58:19 +0000 https://programmerbay.com/?p=6243 Coupling and cohesion are methods to measure the relationship between and within modules.

cohesion vs coupling

A software system is divided into multiple modules, where each and every module are capable of performing a function independently. This technique is known as Modularization.

Further, Coupling and Cohesion indicate to which degree a module can carry out a task on its own and the strength of elements related to one other within that respective module.

Coupling measures interaction between modules whereas Cohesion focuses on interaction within a module.

Difference between Coupling and Cohesion in Tabular form

CouplingCohesion
It refers to relationship between two or more modulesIt refers to relationship between two or more elements within a module
It focuses on measuring a module's dependency with other modulesIt focuses on measuring a module's functional strength
It is ideal to have low coupled modules which states dependency between modulesIt is ideal to have a module with high cohesiveness which states implementation of a particular feature with low or no communication with other module
It is based on communication between two modules. Therefore, it is known as inter-module conceptIt is based on communication between two elements or fields within a single module. Therefore, it is known as intra-module concept
There are 6 types of coupling: Data Coupling,Stamp Coupling,Control Coupling,External Coupling,Common Coupling and Content CouplingThere are 8 types of cohesion: Functional Cohesion,Sequential Cohesion,Communicational Cohesion,Procedural Cohesion,Temporal Cohesion,Logical Cohesion and Coincidental Cohesion
It is not possible to achieve no coupling among all modulesIt is possible to achieve full cohesive modules

Coupling

The measure of how a module depends on other modules is known as coupling.

It can be viewed as highly coupled, loosely coupled and uncoupled. These are based on their degree of dependencies.

Uncoupled signifies no dependencies at all, all the modules or methods have nothing to do with other modules. No communication between this type of coupling takes place.

Highly coupled refers to the high dependency of the module with each other.

Loosely coupled represents less dependency which means that only essential piece of code would depend and communicate with each other. It means undesired data would not be passed to another section of code.

In programming, the ideal way of having a program to be loosely coupled is by using the concept of interfaces.

Coupling can be classified based on certain characteristics:

Coupling

Cohesion

It represents how a module’s attributes or fields are functionally related together. A module that is highly cohesive, has little or no interaction with other modules.

Therefore, it is better to have maximised cohesive modules where elements within a module interact properly to one another.

A module with high cohesion represents that it is strongly capable of performing a particular functionality or task, considering less or no communication with other modules.

Cohesion can be classified based on certain characteristics:

cohesion

A Good Relationship between Cohesion and Coupling

relation

A software with less coupled and high cohesive module design should always be preferred. A software design breaks down into multiple modules where each module solves a particular problem.

These modules are structured in a proper hierarchy. Each and every module must be implemented in a way that they are having less dependency with other modules and the elements within that module should be functionally related together.

]]>
https://programmerbay.com/difference-between-cohesion-and-coupling/feed/ 0