Effective Modular Design
A modular design reduces complexity and result in easier
mentation by encouraging parallel development of different
of a system.
nctional Independence
The concept of functional independence is a direct outgrowth of
lodularity and the concepts of abstraction and information hiding.
+ If we want to design software so that each module addresses a specific
subfunction of requirements and has a simple interface when viewe
from other parts of the program structure at that time functional
independence is achieved.
Software with effective modularity (that is
independent modules) is easier to develop because
function may be compartmentalized and interfaces
are simplified.
Independent modules are easier to maintain
because secondary effects caused by design or code
modification are limited, error propagation is
reduced, and reusable modules are possible.
In short, Functional independence is a
key for good design and design is the key to
software quality.
Independence is measured using two criteria:
(1) Cohesion
(2) Coupling(1) Cohesion
» Cohesion is a measure of the relative functional
strength of a module.
A cohesive module performs a single task within a
software procedure.
We always strive for high cohesion, although the
mid-range of the cohesion is often acceptable.
Cohesion may be represented as a “spectrum”.
At the low end of the spectrum, we encounter a
module that perform a set of tasks that relate to
each other loosely is called coincidentally
cohesive.
A module that performs tasks that are related
logically is logically cohesive.
« When a module contains tasks that are related by the fact
that all must be executed with the same span of time is
called temporal cohesion.
« When processing elements of a module are related and
must be executed in specific order, procedural cohesion
exists.
« When all processing elements concentrate on one area of
a data structure, communicational cohesion is present.
+ High cohesion is characterized by a module that performs
one distinct procedural task.(2) Coupling
» Coupling is a measure of interconnection (the relative
interdependence) among modules.
Coupling depends on the interface complexity between
modules, the point at which entry or reference is made
to a module, and what data pass across the interface.
- In software design we strive for lowest possible
coupling.
\
/ wr \ \
Js ( \ \
HJ) EL oot co
win o™ J ~
x. : / \
IE /
v Y 1 J
sil dts as
Figure: Types of couplingIn figure Modules a and d are subordinate to different
modules.
Each is unrelated and therefore no direct coupling occurs.
Module c is subordinate to module a and is accesses via a
conventional argument list, through which data are
passed.
As long as simple argument list is present, low coupling
(data coupling) is exhibited in this portion of structure.
A variation of data coupling, called stamp coupling is
found when a portion of a data structure (rather than
simple arguments) is passed via a module interface. This
occurs between modules b and a.
Coupling is characterized by passage of control between
modules is called control coupling.
In figure a “control flag” (a variable that controls decisions
in a subordinate or superordinate module) is passes
between modules d and e.
When modules are tied to an environment external to
software, high levels of coupling occur.
for eg. I/O couples a module to specific devices,
formats, and communication protocols.
External coupling is essential but should be limited to a
small number of modules with a structure.+ High coupling also occur when number of modules
reference a global data area.
+ Common coupling, as this mode is called, is shown in
figure. Modules c, g and k each access a data item ina
global data area (eg. A disk file or a globally accessible
memory area).
« The highest degree of coupling, content coupling, occurs
when one module makes use of data or control
information maintained within the boundary of another
module.
Design heuristics for effective
modularity
once program structure has been developed, effective
modularity can be achieved by applying the design
concept. The program structure can be manipulated
according to the following set of heuristics:
. Evaluate the “first iteration” of the program structure to
reduce coupling and improve cohesion,
. Attempt to minimize structures with high fan-out; strive
for fan-in as depth increases.
. Evaluate module interfaces to reduce complexity and
redundancy and improve consistency.