WHAT IS COHESION AND TYPES OF COHESION IN SHORTLY
Cohesion in software engineering refers to the degree of
interrelatedness or togetherness of elements within a module or
component. It measures how closely the components work together
to achieve a common goal.
Types of Cohesion:
Functional Cohesion:
Elements within a module contribute to a single, well-defined task or
functionality.
Sequential Cohesion:
Elements are executed in a specific sequence, with the output of one
being the input for the next.
Communicational Cohesion:
Elements within a module operate on the same data or share data
through parameters.
Procedural Cohesion:
Elements are grouped together based on the order of execution.
Temporal Cohesion:
Elements are grouped because they are executed at the same time,
often within the same event or function call.
Logical Cohesion:
Elements are grouped based on a logical relationship but may
perform diverse tasks.
Coincidental Cohesion:
Elements are grouped without a meaningful relationship, often due
to historical or accidental reasons.
COHESION:
Cohesion: Cohesion is a measure of the degree to which the
elements of the module are functionally related. It is the degree to
which all elements directed towards performing a single task are
contained in the component. Basically, cohesion is the internal glue
that keeps the module together. A good software design will have
high cohesion.
In computer programming, cohesion defines to the
degree to which the elements of a module belong
together. Thus, cohesion measures the strength of
relationships between pieces of functionality within a
given module. For example, in highly cohesive systems,
functionality is strongly related.
In software engineering, cohesion refers to the degree to which
the components within a module or a software unit work
together to achieve a common purpose. It is a measure of the
strength of the relationships among the elements (e.g.,
functions, classes, or modules) within a software module. In
essence, cohesion assesses how closely the parts of a module
are related and how well they collaborate to perform a specific,
well-defined functionality.
TYPES OF COHESION
Functional Cohesion:
Elements within a module are grouped together because they all
contribute to a single, well-defined task or functionality. This is the
strongest and most desirable type of cohesion.
Sequential Cohesion:
Elements are arranged in a sequential order, where the output of one
element serves as the input to the next. The order of execution is
crucial for achieving the desired functionality.
Communicational Cohesion:
Elements within a module operate on the same data or share data
through parameters. While they may perform different tasks, they
use the same data.
Procedural Cohesion:
Elements are grouped together based on the order in which they are
executed. This type of cohesion is common in procedures or
functions that perform a series of steps.
Temporal Cohesion:
Elements within a module are grouped together because they are
executed at the same time, such as being part of the same event or
function call.
Logical Cohesion:
Elements are grouped together based on a logical relationship, but
the tasks they perform may be diverse. Logical cohesion is often a
weaker form of cohesion compared to functional cohesion.
Coincidental Cohesion:
Elements within a module are grouped together without a
meaningful relationship. This is the weakest form of cohesion and is
often a sign of poor design.
Types of Cohesion:
ntribute to a single well-defined function or purpose, and there is
little or no coupling between the elements. Functional cohesion is
considered the most desirable type of cohesion as it leads to more
maintainable and reusable code.
Layer Cohesion: Layer cohesion occurs when elements or tasks in a
module are grouped together based on their level of abstraction or
responsibility, such as a module that handles only low-level hardware
interactions or a module that handles only high-level business logic.
Layer cohesion is commonly used in large-scale software systems to
organize code into manageable layers.