Cohesion:
Cohesion is the degree to which the elements inside a module belong together. It is a measure of the functional strength of a module. Cohesion is defined as the degree to which the elements of a particular module are functionally related. Cohesion of a module represents how tightly bound the internal elements of the module are to one another.The measure of how strongly the elements are related functionally inside a module is called cohesion. It is a measure that defines the degree of intra-dependability within an element of a module. A good software design will have high cohesion. A module with high cohesion contains elements that are tightly related to each other and united in their purpose. A module is said to have low cohesion if it contains unrelated elements.
Types of
Cohesion:
Functional Cohesion: Functional Cohesion is said to exist if the different elements of a module, cooperate to achieve a single function. This is the best cohesion and the ideal one. In functional cohesion, the elements of module are grouped together because they all contribute to a single function. This is the most desirable type of cohesion. It is considered to be the highest degree of cohesion.
Sequential Cohesion: Sequential cohesion occurs when the output of one
element is the input for the next element. In this cohesion technique, output
from one part of the module is an input to some other element of the same
module.
Communicational Cohesion: A
module is said to have communicational cohesion, if all tasks of the module
refer to or update the same data structure.
Procedural Cohesion: A
module is said to be procedural cohesion if the set of purpose of the module
are all parts of a procedure in which particular sequence of steps has to be
carried out for achieving a goal.
Temporal Cohesion: The elements are related by
their timing involved. A module connected with temporal cohesion all the tasks
must be executed in the same time span. This cohesion contains the code for
initializing all the parts of the system. Lots of different activities occur,
all at unit time.
Logical Cohesion: A
Module has Logical Cohesion only if there is some Logical relationship between
the elements of the module.
The elements are logically related and not functionally.
Coincidental Cohesion: The elements are not related (unrelated). The elements have no conceptual relationship other than location in source code. It is accidental and the worst form of cohesion.
Coupling:
Coupling is the
degree of interdependence between software modules. Coupling
between modules is the strength of interconnections between modules and a
measure of interdependence among modules. Two
modules with high coupling are strongly interconnected and thus dependent on
each other. Modules should have low coupling. Two modules with low coupling are
not dependent on one another.
Coupling is defined as the degree to
which the two modules are dependent on each other. It measures the strength of
relationships between modules. Coupling between any
two modules is identified from the number and types of resources that the
modules share with other modules.
Types of Coupling:
Data Coupling: If the dependency between the modules is based on
the fact that they communicate by passing only data, then the modules are said
to be data coupled. In data coupling, the components are independent of each
other and communicate through data. This is the
desirable type of coupling.
Stamp Coupling In stamp coupling, the complete data structure is
passed from one module to another module.
Control Coupling: Control coupling is one
module controlling the flow of another, by passing it information on what to
do. If the modules
communicate by passing control information, then they are said to be control
coupled.
External Coupling: In external coupling, the modules depend on other
modules, external to the software being developed or to a particular type of
hardware. Ex- protocol, external file, device format, etc.
Common Coupling: Common coupling is said
to occur when several modules have access to the same global data. The modules have
shared data such as global data structures.
Content Coupling: Content coupling is said to occur when one module uses the data of other module. In a content coupling, one module can modify the data of another module, or control flow is passed from one module to the other module. This is the worst form of coupling and should be avoided.
Difference
between Coupling and Cohesion:
Cohesion |
Coupling |
Cohesion
is the degree to which the elements inside a module belong together |
Coupling
is the degree of interdependence between the modules. |
A
module with high cohesion contains elements that are tightly related to each
other and united in their purpose. |
Two modules with high coupling are strongly interconnected
and thus dependent on each other. |
A module is said to have low cohesion if it contains unrelated
elements. |
Two modules with low coupling are not dependent on one another. |
Highly
cohesive module reflects higher quality of software design. |
Loose
coupling reflects the higher quality of software design |
Cohesion
is Intra – Module Concept |
Coupling
is Inter -Module Concept |
0 Comments
if you have any doubts plz let me know...