Coupling (computer programming)

This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 20:10, 19 May 2005 (subclass coupling merged; add {{cleanup}}). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

You must add a |reason= parameter to this Cleanup template – replace it with {{Cleanup|reason=<Fill reason here>}}, or remove the Cleanup template.

In computer science, dependency is a state where one object uses a functionality of another object. This may cause changes on implementation of one object can affect that of another object. Supposedly, Information hiding is a way to eliminate dependency to limit influence of changes and improve modularity. Dependencies can be reduced by applying the dependency inversion principle. Examples of dependency relationships are aggregation (is-part-of), inheritance (is-a), subtyping, uses and implements relationships.

It also is common in talking about software package management. One software package, in order to work or to be fully functional, may depend on other software packages and thus must be installed also, and their specific versions must be known if backward compatibility is broken between versions. The Apt package format, as well as some versions of the RPM package format, include dependency information between packages. This is convenient for updating software but can lead to dependency hell.


In computer programming, coupling refers to the degree to which each program module relies on each other module. Coupling can be "high" (or "tight"), or "low" (or "loose"). Low coupling means that one module does not have to be concerned with the internal implementation of another module. Low coupling is a sign of a well structured computer system. However, in order to achieve maximum efficiency, a highly coupled system is probably needed. In modern computing systems, performance can often be traded for low coupling; the gains in the software development process are greater than the value of the running performance gain.

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).
  • In object-oriented programming, subclass coupling describes a special type of coupling between a parent class and its child. The parent has no connection to the child class, so the connection is one way (i.e. the parent is a sensible class on its own). The coupling is hard to classify as low or high; it can depend on the situation.

Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.