Coupling (coupling), also known as coupling degree, is a measure of the degree of association between modules. The strength of the coupling depends on the complexity of the interface between modules, how the module is called, and how much data is transferred through the interface. The coupling degree between modules refers to the dependencies between modules, including control relationships, call relationships, and data transfer relationships. The more connections between modules, the stronger the coupling, and the lower the independence of the module. In software design, coupling degree and cohesion are usually used as the standard to measure the independence degree of the module. One of the criteria for partitioning a module is cohesion-poly-low coupling.
There are seven possible connections between the general modules, which constitute seven types of coupling. The relationship between them is (strong to weak coupling):
-
content Coupling (coupling)
Content coupling occurs between two modules if the following conditions occur.
- One module accesses the internal data of another module directly;
- One module does not pass through the normal entrance to the inside of another module;
- Two modules have part of the program code overlap (can only appear in assembly language);
- A module has multiple entrances.
-
Public coupling (Common coupling)
If a set of modules accesses the same common data environment, the coupling between them is called public coupling. A public data environment can be a global structure, a shared communication area, a common area of memory, and so on.
-
external coupling (External coupling)
A set of modules accesses the same global simple variable instead of the same global data structure, and it is not the information of the global variable passed through the parameter table, it is called an external coupling.
-
controlled coupling (control coupling)
If a module through the transmission of switches, signs, names and other control information, obviously control the selection of another module function, is to control the coupling.
-
imprinting coupling (Stamp coupling)
If a set of modules passes the record information through the parameter table, it is the tag coupling. It is a substructure of a data structure, not a simple variable.
-
data Coupling (coupling)
If a module accesses another module, the input and output information is exchanged between each other through data parameters (not control parameters, public data structures, or external variables), the coupling is said to be data-coupled.
-
Non-direct coupling (nondirect coupling)
If there is no direct relationship between the two modules, the connection between them is entirely through the control and invocation of the main module, which is the non-direct coupling. This coupling has the strongest module independence.
Various types of coupling in software engineering