Yes,
very much so. The worst kind of coupling occurs when one class modifies the
data in another class. Passing large (partially unused) data structures
around is also found upon.
The
types of coupling, in order of lowest to highest coupling, are as follows:
- Data coupling - Data
coupling is when modules share data through, for example, parameters.
Each datum is an elementary piece, and these are the only data which
are shared (e.g. passing an integer to a function which computes a
square root).
- Stamp coupling
(Data-structured coupling) - Stamp coupling is when modules share a
composite data structure, each module not knowing which part of the
data structure will be used by the other (e.g. passing a student
record to a function which calculates the student's GPA).
- Control coupling - Control
coupling is one module controlling the logic of another, by passing it
information on what to do (e.g. passing a what-to-do flag).
- External coupling -
External coupling occurs when two modules share an externally imposed
data format, communication protocol, or device interface.
- Common coupling - Common
coupling is when two modules share the same global data (e.g. a global
variable).
- Content coupling - Content
coupling is when one module modifies or relies on the internal
workings of another module (e.g. accessing local data of another
module). (ref)
So far
we have been considering static coupling. What about dynamic coupling. Why
might this add complexity to the issue?
By
considering Dynamic coupling we are considering temporal dependencies (i.e.
dependencies in execution order) between classes. Problems can occur in
highly coupled classes when they expose observable state as the order (or
even worse the timing) in which individual methods on a class are called
must be maintained.
|