degree of connectivity among the elements of a single module and in Object-oriented design, a single class/object
Maximize internal interaction (intramural) among subelements
Minimize external interaction (extramural) with other elements
p
, modifies a statement of another module, q
p
, references or alters the local data of another module,
q
p
, branches into another module, q
q
requires a change to module p
, including
recompilationp
requires using module q
Multiple modules accessing and modifying the same database tables without any form of isolation
p
passes an argument to module q
that directly tells
it what control structure path to takeBetween derived and base class
When a component relies on an external system or service. For instance, coupling to a specific database engine or a third-party library.
When several modules share global data. Global variables are the most common form of this.
When the timing and order of operations are critical. For example, one function must be called before another to maintain state.
init()
must be called before using other functions from a moduleIDLE
to READY
before it can process tasksSometimes, different modules are coupled so that they must be modified together whenever a change occurs. Even if the modules do not directly interact, a change in one often requires changes in the others.
Sometimes, coupling is not obvious and is based on assumptions. For instance, two classes might be implicitly coupled if they rely on the same configuration setting, even if they do not directly interact.
In large systems, different subsystems can have varying degrees of coupling between them
This occurs when modules depend on some conceptual or domain-specific logic that isn't explicitly coded. This can be hard to spot just by looking at the code, as it may require domain knowledge to identify.
A random or unplanned coupling that occurs without any logical relationship between the coupled modules. Such coupling is generally considered undesirable as it can be error-prone and make the system harder to understand.
In dynamic languages or runtime-generated code, coupling can happen dynamically during the execution of the program. This makes it more difficult to analyze and manage.
This refers to the situation where one function calls another function and relies entirely on its output. In some cases, this might be an acceptable or even necessary form of coupling.
sin()
function relying on a radianToDegree()
function from the same library