In computer science, coupling or dependency is the degree to which each program module relies on each other module.
Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. The software quality metrics of coupling and cohesion were invented by Larry Constantine, original developer of Structured Design (see also SSADM).
However, in order to achieve maximum efficiency, a highly coupled system is sometimes needed. In modern computing systems, performance is often traded for lower coupling; the gains in the software development process are greater than the value of the running performance gain.
Low-coupling / high-cohesion is a general goal to achieve when structuring computer programs, so that they are easier to understand and maintain.
The concepts are usually related: low coupling implies high cohesion and vice versa. In the field of object-oriented programming, the connection between classes tends to get lower (low coupling), if we group related methods of a class together (high cohesion).
In object-oriented programming, coupling is a measure of how strongly one class is connected to another.
Coupling is increased between two classes A and B if:
Disadvantages of high coupling include:
One measure to achieve low coupling is functional design: it limits the responsibilities of modules. Modules with single responsibilities usually need to communicate less with other modules, and this has the virtuous side-effect of reducing coupling and increasing cohesion in many cases.
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.
In the first instances of the IBM PC, BIOS, some developers used low level but undocumented internal functions to optimize their programs, instead of the public API. This approach had the advantage of bringing higher performance, but as a result the programs were more complex, more difficult to maintain, and the internal functions could change on a subsequent BIOS version.
Build systems like make are also dependency driven in the sense that a more complex object, like a program, only gets linked together once all its dependencies, i.e. the objects it is built of, have been compiled.
High cohesion and low coupling are attributes of good design.
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Coupling (computer science)".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world