Varieties of Coupling

So, how does coupling occur? Here are some examples of coupling, arranged from very tight coupling, which is considered bad, to much looser coupling.

Internal data coupling refers to one object needing the values held internal to another component in order to do it work. That is like one object needing to know, or worse to modify, the internal state of another object. This makes it very hard to study objects in isolation, or to carry an individual object to another project.

Almost as bad is data coupling through the use of global variables. Global variables are difficult to handle in programs because they are global, and hence it is difficult to know where they are set and/or used without examining the entire program. Again, this makes it hard to understand sections of a program in isolation.

Control or sequence coupling occurs when one object must perform a task before another can complete its task, but they otherwise have no direction connections. Since the time element may not be physically represented in the program, it also makes it difficult to understand one component in isolation.

Parameter coupling occurs when information is passed from one component to another across the function call boundary. This connection is overt, easy to recognize, and this much easier to handle than the others.

Finally, the coupling between a parent class and a child class is one-way, and hence even more benign than the caller-callee connection. Subclass coupling does not prevent the parent class from being carried to a new project. Thus, this is a very desirable form of coupling.

[audio] [real] Text to accompany slide6, in Chapter 17 of An Introduction to Object-Oriented Programming