[641 COUPLING hepunte
tionship between two modules in a software
Couphngy is a feature desenbing the inte
‘atl a measure of degrec of dependency of design modules ma
Wericies among modules 1s not the only Kretor lo mesure
determined based on the complexity of
he other module.
agn higrerehs. In other words, i
are siucture, The number of depe
The strength of interconnection between modules 1s
that are interchanged When one module invokes the functions of |
r 90 coupl
. par.
ea ¢ sai be,
+ ad !
oe as thehly coupled, When the modules are highly dependent on cach other Highly coupled mod-
les are yoined by Mrong interconnections,
» : Interconnections,
other but the interconnection
Toosely coupled | When the modules are dependent on each
between them is weak
Uncoupled | When no interconnection exists between modules. In such case. no step mm one
lationship
module can affect the steps of the other module. Moreover, there is ne direct re!
between a pan of moduies through t : sharing of comman variables,
One should remember that coupling between modules ty largely decided dunng system de-
sign and cannot be reduced further during coding.
isan abstract concept, no formula is available to dgtermine the coupling between
tors that miflucnce coupling between modules
yn between modules : Coupling increases af
per module exists and each interface is very com, lex, So it should be kept as low
Also exchange of miformauion between modules should be made only through parameters. Use
a large number of interfaces
as possible.
of shared variables should be reduced.
J_-Compleany of interface Higher 1s the compiexity of an interface, higher will be the degree of
es{oftware Design
coupling. We should try to keep interface of a module small and simple. So if a single field is
FEqujred, entire record should not be passed thereby avoiding increase in coupling unnecessarily.
foe of information flow along the interface : To keep coupling low, only data should be
i To keep couping ae
passed and recetved trom other modules. Passing or receiving control imformation makes mod=
ules highly interdependent,
6) PES OF COUPLING
t
E
There are different ways in which modules can be coupled. These types are discussed
below in order of increasing coupling.
E
;
:
J Data coupling : When two modules of the software communicate using an elementary data
item thet is passed as a parameter between the two then the two modules are data . coupled. For
example, an integer, a float, a character etc. This data item should be problem related and not
for catrol purpose” When a nomglobal variable is Se atic c 5 are called
eee led Tis the lowest form of c
module in C and receiving’ the v:
of coupling. For example, passing the variable from one
i ng the aneule| ony
by value: onal.
\2famp coupling : When the caller module passes more information than needed to the called
modale thei the two modules &é stamp coupled. For example, instead of passing a field; entire
record (in Pascal) or strUctife (in C) is passed to the module. Thus, exposing more data than
required can lead to undesirable side effects.
<3e*Control coupling : When one module passes a piece of data or sitnal to control the action of
another module, they are said to be control coupled. The control information tells the callec.|
module what actions to perform) Example - Passing of control flag or variable among input
execute appropriate steps. So the called module is controlling the execution of the calle module.
parameters passed to the callee module. The callee module uses received flag to select and coal
|
mmon coupling :_ When two modules share the same global data variable amichure or data
file. Diagnosing problems in structures with considerable common coupling i time Constihin,
and difficult. However, common coupling is sometinics unavoidable as modules inight neo to
faePemenen data stores to perfofm their functions. This type of coupling leads to potential side
effects and thereby increases chan: nnd Towers maintainability, The level of
module interdependence becomes quite high in such cases.
5. ‘alent coupling : When one module directly refers to (modify or rely) internal details of
RE oy are said to be conjent coupled; Example - When one module includes @
statement to jump and execute inside otter module or when one module changes the contents of
variable inside other module. In this
| pling can exis haw. a. :
ed No Data | stamp | Control | Common | Content
| Coupling | Coupling | Coupling | Coupling | Coupling | Coupling
‘
tFUNDAMENTALS OP SOP FWARE ENGINE HANG
The Fig, 6.5 illustrates ekiss
jeaton of couphiys with incre
pling with least level is considered the best among: thes
Mt Mong Modules Hot only makes the desig
totu, but it also increases develo,
nyt level of coupling. The cou
h couplin
en difficult to understand and min
NW effort as the module
oped independently by different team members
ment and debug,
et
6.4.2 COHESION Relohonsh’h
Cohesion is the mea sure of rel
sures how tightly bound th
Jar purpose, Wis an internal i
Naving high coupling: cauuot be devel
Modules inaving high coupling are
cult to imple
ative functional strength of a module, In otter words, it mea
ements of a module ate 16 one another for achieving a particu-
ture ofa module ina piven sofware design. A designer aim at highly
assessed once the high Tevel design 15 con:
SS
cohesive modules. Cohesi
plete. Mighty cohesive sn ested,
ter is the cohes
Cohi on; lower is the coupling betweer:
modules. Di 's of cohesion are discusseOBCIOW. THESe are ontereP Tom worst to best
| cohesion types.
Pe
(+ CoincidentaL cohesion : A module is said to be coincidentally cohesive when there is na
meaningful relationship among the elements of a module. In such a case, a module contai
Fandom collection of functions. It means that the functions have been put in the module wither
any thought of the design (Absolute beginners often bundle function modules rather arbitrarily.
For example, cqnsider # module that gets some input, performs searching then sorting and finally
‘Untr prints the outpet. Cohesiv of modules can be improved by clus ring relating steps togethe:
6, and splitting the module into wo or more modules, each with higher colasive levels, tt should be
remembered that modules with coincidental cohesion are hardly reusable and maintainable.
‘ogical cohesion : A module is said to be logically cohesive if tere is some k