0% found this document useful (0 votes)
61 views27 pages

Asst - Prof. Sunitha E.V: Department of Information Technology Tist

The document discusses cohesion and coupling in software modules. It defines cohesion as the functional strength of a module and describes high cohesion as a module performing a single well-defined task. Coupling is defined as the degree of interdependence between modules. High cohesion and low coupling are desirable as they result in modules that are functionally independent, easier to understand and reuse. The document then classifies different types of cohesion and coupling to help evaluate the degree to which a module exhibits these properties.

Uploaded by

Hafneem Asharaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views27 pages

Asst - Prof. Sunitha E.V: Department of Information Technology Tist

The document discusses cohesion and coupling in software modules. It defines cohesion as the functional strength of a module and describes high cohesion as a module performing a single well-defined task. Coupling is defined as the degree of interdependence between modules. High cohesion and low coupling are desirable as they result in modules that are functionally independent, easier to understand and reuse. The document then classifies different types of cohesion and coupling to help evaluate the degree to which a module exhibits these properties.

Uploaded by

Hafneem Asharaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 27

Asst.Prof. Sunitha E.

V
Department of Information Technology
TIST
 In
technical terms, modules
should display:
◦ High cohesion
◦ Low coupling.
 We shall next discuss:
◦ cohesion and coupling.
 Cohesion is a measure of:
◦ functional strength of a module.
◦ A cohesive module performs a
single task or function.
 Coupling between two modules:
◦ A measure of the degree of the
interdependence or interaction
between the two modules.
Amodule having high
cohesion and low coupling:
◦ functionally independent of
other modules:
 A functionally independent
module has minimal interaction
with other modules.
 Better understandability and
good design:
 Complexity of design is reduced,

 Different modules easily

understood in isolation:
◦ Modules are independent
 Functional independence reduces
error propagation.
◦ Degree of interaction between
modules is low.
◦ An error existing in one module does
not directly affect other modules.
 Reuse of modules is possible.
 A functionally independent module:
◦ Can be easily taken out and reused in
a different program.
 Each module does some well-defined
and precise function
 The interfaces of a module with other
modules is simple and minimal.
 Unfortunately, there are no ways:
◦ To quantitatively measure the
degree of cohesion and coupling.
◦ Classification of different kinds of
cohesion and coupling:
 Can give us some idea regarding
the degree of cohesiveness of a
module.
 Classification is often subjective:
◦ Yet gives us some idea about
cohesiveness of a module.
 By examining the type of
cohesion exhibited by a module:
◦ We can roughly tell whether it
displays high cohesion or low
cohesion.
functional
sequential
communicational Degree of
procedural cohesion

temporal
logical
coincidental
 The module performs a set of tasks:
◦ Which relate to each other very
loosely, if at all.
 The module contains a random
collection of functions.
 Functions have been put in the module
out of pure coincidence without any
thought or design.
 All elements of the module
perform similar operations:
◦ e.g. error handling, data input,
data output, etc.
 An example of logical cohesion:
◦ A set of print functions to
generate an output report
arranged into a single module.
 The module contains tasks that are
related by the fact:
◦ All the tasks must be executed in the
same time span.
 Example:
◦ The set of functions responsible for
 initialization,
 start-up, shut-down of some process,
etc.
 The set of functions of the module:
◦ All part of a procedure (algorithm)
◦ Certain sequence of steps have to be
carried out in a certain order for
achieving an objective,
 e.g. the algorithm for decoding a message.
 All functions of the module:
◦ Reference or update the same data
structure,
 Example:
◦ The set of functions defined on an
array or a stack.
 Elements of a module form
different parts of a sequence,
◦ Output from one element of the
sequence is input to the next.
◦ Example:
sort

search

display
 Different elements of a module
cooperate:
◦ To achieve a single function,
◦ e.g. managing an employee's pay-roll.
 When a module displays functional
cohesion,
◦ We can describe the function using a
single sentence.
 Write down a sentence to describe
the function of the module
◦ If the sentence is compound,
 It has a sequential or communicational
cohesion.
◦ If it has words like “first”, “next”,
“after”, “then”, etc.
 It has sequential or temporal cohesion.
◦ If it has words like initialize,
 It probably has temporal cohesion.
 Coupling indicates:
◦ How closely two modules
interact or how interdependent
they are.
◦ The degree of coupling
between two modules depends
on their interface complexity.
 There are no ways to precisely
determine coupling between two
modules:
◦ Classification of different types of
coupling will help us to approximately
estimate the degree of coupling between
two modules.
 Five types of coupling can exist
between any two modules.
data
stamp
control Degree of
coupling
common
content
 Two modules are data coupled,
◦ If they communicate via a parameter:
 an elementary data item,
 e.g an integer, a float, a character,
etc.

◦ The data item should be problem


related:
 Not used for control purpose.
 Twomodules are stamp
coupled,
◦If they communicate via a
composite data item
 such as a record in PASCAL
 or a structure in C.
 Datafrom one module is
used to direct:
◦ Order of instruction execution
in another.
 Example of control coupling:
◦ A flag set in one module and
tested in another module.
 Twomodules are common
coupled,
◦ If they share some global data.
 Content coupling exists between
two modules:
◦ If they share code,
◦ e.g, branching from one module into
another module.
 The degree of coupling increases
◦ from data coupling to content
coupling.

You might also like