Effective Modular Design

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Modular Design

• A system is considered modular if it consists of


discrete modules so that each module can be
implemented separately, and a change to one
module has minimal impact on other modules.
• A modular design reduces complexity,
facilitates change and results in easier
implementation by encouraging parallel
development of different parts of a system.
Functional Independence
• Each module addresses a specific sub function
of requirements
• Error propagation is reduced and reusable
modules are possible.
• Independence measured using quality criteria
cohesion and coupling.
Cohesion
• Cohesion is a measure of the relative functional
strength of a module.
• Cohesion of a module represents how tightly
bound the internal elements of the module are
to one another.
• A cohesive module performs a single task
within a software procedure, requiring little
interaction with procedures being performed in
other parts of a program.
Levels of Cohesion
1. Coincidental
• Coincidental cohesion occurs when there is
no meaningful relationship among the
elements of a module.
• In this case, the module contains a random
collection of functions.
• For example, in a transaction processing
system(TPS), the get-input, print-error are
grouped into one module.
2. Logical
• A module is said to be logically cohesive, if all
elements of the module perform similar
operations, e.g. error handling, data input,
data outputs, etc.
• An example of logical cohesion is the case
where a set of print functions generating
different output reports are arranged into a
single module.
• Flag is used
3. Temporal
• When a module contains functions that are
related by the fact that all the functions must
be executed in the same time span, the
module is said to exhibit temporal cohesion.
• The set of functions responsible for
initialization, start-up, shutdown of some
process, etc. exhibit temporal cohesion.
• Flag is avoided
4. Procedural
• A module is said to possess procedural
cohesion, if the set of functions of the module
are all part of a procedure(algorithm).
• For example, a loop or a sequence of decision
statements in a module may be combined to
form a separate module.
• Procedurally cohesive modules often occur
when modular structure is determined from
some form of flowchart.
5. Communicational
• A module is said to have communicational
cohesion, if all functions of the module refer
to or update the same data structure, e.g. the
set of functions defined on an array or a
stack.
• A module with communicational cohesion
has elements that are related by a reference
to the same input or output data.
6. Sequential
• A module is said to possess sequential
cohesion, if the elements of a module form
the parts of sequence, where the output
from one element of the sequence is input to
the next.
• For example, in a TPS, the get-input, validate-
input, sort-input functions are grouped into
one module.
7. Functional
• Functional cohesion is said to exist, if
different elements of a module cooperate to
achieve a single functions.
• Functions like “compute square root” and
“sort the array” are clear examples of
functionally cohesive modules.
Coupling
• Coupling between modules is the strength of
interconnections between modules or a
measure of interdependence among modules.
• In general, the more we must know about
module A in order to understand module B, the
more closely connected A is to B.
• “Highly coupled” modules are joined by strong
interconnections, while “loosely coupled”
modules have weak interconnections.
• Coupling increases with the complexity of the
interface between modules.
• To keep coupling low we would like to
minimize the number of interfaces per module
and the complexity of each interface.
• An interface of a module is used to pass
information to and from other modules.
• For example, complexity of an interface of a
procedure depends on the number of items
being passed as parameters and on the
complexity of the items.
• For example, if a field of a record is needed by
a procedure, often the entire record is passed,
rather than just passing that field of the
record. By passing the record we are
increasing the coupling unnecessarily.
Classification of Coupling

Data: Modules communicate through data item such as integer

Stamp: Modules communicate through composite data item such as


structure

Control: Data from one module directs other module e.g. flag

Common: Two modules share global data item

Content: Modules share code

You might also like