Coupling and decoupling

coupling:

  1. Coupling refers to the phenomenon in which two or more systems or two forms of motion influence each other and even unite through interaction.
  2. In software engineering, the degree of coupling between objects is the dependence 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.
  3. Classification: 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.

Decoupling:

  1. Decoupling, literally means decoupling. In software engineering, reducing the degree of coupling can be understood as decoupling. If there are dependencies between modules, there must be coupling. In theory, absolute zero coupling cannot be achieved, but the degree of coupling can be minimized by some existing methods. .
  2. The core idea of ​​the design: reduce code coupling as much as possible. If code coupling is found, decoupling technology must be adopted. Let the data model, business logic and view display reduce the coupling between the three layers, and minimize the correlation dependence, so as not to affect the whole body. The principle is that the code of function A should not be written in the function code of B. If there is a need for interaction between the two, you can use interfaces, messages, or even introduce frameworks, but in short, don't cross-write directly.

 

Guess you like

Origin blog.csdn.net/qq_44624536/article/details/114265375