Coupling is the measure of the interdependence of one module to another.
Modules should have low coupling. Low coupling minimizes
the "ripple effect" where changes in one module cause errors in
No Direct Coupling
These are independent modules and so are not really components
of a single system.
Two modules are data coupled if they communicate
by passing parameters. This has been told to you
as a "good design principle" since day one of your
Two modules are stamp coupled if they communicate via a
passed data structure that contains more information than
necessary for them to perform their functions.
Two modules are control coupled if they communicate using at least
one "control flag".
Two modules are common coupled if they both share the same
global data area. Another design principle you have been
taught since day one: don't use global data.
Two modules are content coupled if:
- one module changes a statement in another (Lisp was famous for this ability)
- one module references or alters data contained inside another module
- one module branches into another module
Type 2 can be done in, say, Pascal by using the language
scope rules to do non-local referencing... read and write the
values of variable in one procedure from another one (assuming
a procedure is considered a module)
A worse example of type 2 is if you use a language like Simula
in which you can create objects (data and procedures to operate
on that data, in a module) but then you violate the object boundaries
by directly reading and writing the variable in the object. Later
OO languages (C++, Eiffel) prevent this, but earlier ones do not.
Type3 can be done in Pascal... branch from one procedure to a
label in another... using scope rules.