Coupling and decoupling procedure (callback function is essentially decoupled)

A coupling

1, the coupling means between two or more systems or two forms of movement by interaction affect each well together phenomenon.

2, in software engineering, is the degree of coupling between objects dependencies between objects. The higher the coupling between objects, higher maintenance costs, so the design should minimize the object class and the coupling between the member.

3, Classification: coupling between the coupling, as well as hardware and software between the software modules. Coupling is a measure of the program structure of the linkages between the various modules. It depends on the complexity of the interface between each module, the calling module and what information the way through the interface.

Second, decoupling

1, decoupling, literally means to decouple the relationship.

2, in software engineering, i.e. to reduce the degree of coupling can be understood as decoupling, dependent relationship must exist between the coupling module, coupled to the theoretical absolute zero is impossible, but can be identified by conventional methods to reduce the degree of coupling to a minimum.

3, the design of the core idea: to minimize coupling of code, if the code is coupled found, it is necessary to take decoupling technology. Let data model, business logic and views between the three lower display coupled to one another, the association relies to a minimum, and thus will not affect the situation as a whole. A principle feature of the code is not written in the function code B, if needed interaction between the two, through the interface, through a message, or even the introduction of the framework, but in short, is not to write directly cross.

4, the observer pattern: the meaning of existence observer pattern is the "decoupling", it makes logical observer and the observed are no longer entangled with, but independent of each other, are not mutually dependent. Such as Netease news night mode, when the user switches to night mode, the observer will notify all observers' settings are changed, it quickly covered with a mask it. " After the QQ push the message sent, it is necessary to push a bomb on the notification bar, but also marked a small red dot on the desktop, but also clever with the observer and the observed.

Guess you like

Origin www.cnblogs.com/still-smile/p/12047984.html