coupling?

What is coupling?

Simply put, the degree of coupling between objects in software engineering is the dependence between objects. The main problem that guides the use and maintenance of objects is the multiple dependencies between objects. The higher the coupling between objects, the higher the maintenance cost. Therefore, the design of objects should minimize the coupling between classes and components.

There are couplings between software and hardware, as well as couplings between software modules.

Coupling is a measure of the correlation between the various modules in the program structure. It depends on the complexity of the interface between the various modules, the way the modules are called, and what information passes through the interface.

Coupling can be divided into the following types, and the degree of coupling between them is arranged from high to low as follows:
(1) Content coupling. When a module directly modifies or manipulates the data of another module, or when a module transfers to another module without passing through the normal entry, such coupling is called content coupling. Content coupling is the highest degree of coupling and should be avoided.
(2) Common coupling. Two or more modules refer to a global data item. This coupling is called common coupling. In a structure with a large number of common couplings, it is very difficult to determine which module assigns a specific value to a global variable.
(3) External coupling. A group of modules all access the same global simple variable instead of the same global data structure, and the information of the global variable is not passed through the parameter table, which is called external coupling.
(4) Control coupling. One module transmits a control signal to another module through the interface, and the module receiving the signal performs appropriate actions according to the signal value. This coupling is called control coupling.
(5) Mark coupling. If a module A passes a common parameter to two modules B and C through the interface, then it is said that there is a tag coupling between the modules B and C.
(6) Data coupling. Passing data between modules through parameters is called data coupling. Data coupling is the lowest form of coupling. This type of coupling generally exists in the system, because in order to complete some meaningful functions, it is often necessary to use the output data of some modules as the input data of other modules.
(7) Indirect coupling. There is no direct relationship between the two modules, and the connection between them is achieved entirely through the control and invocation of the main module.

Summary: Coupling is an important factor affecting software complexity and design quality. In design, we should adopt the following principles: If there must be coupling between modules, try to use data coupling as much as possible, use less control coupling, and limit the scope of common coupling as much as possible. Avoid using content coupling.

Guess you like

Origin blog.csdn.net/RookiexiaoMu_a/article/details/90168565
Recommended