/** * Observer mode * Overview: * During the software build process, we need to establish a "notification dependency" for certain objects--a change in the state of an object (the target object), All dependent objects (Observer objects) will be notified. If such dependencies are too tight, the software will not be able to withstand changes very well. * using object-oriented technology, you can weaken this dependency and form a stable dependency relationship. * to achieve loose coupling of software architecture. * Define a one-to-many dependency between objects, and when the state of an object changes, all objects that depend on it are notified and automatically updated. * * Achieve effect * 1. Using object-oriented abstraction, the Observer pattern allows us to independently change the target and the observer, so that the dependency between them is loosely coupled. * 2. When a target sends a notification, there is no need to specify the observer, and the notification (which can carry notification information as an argument) is automatically propagated. * observers themselves decide whether to subscribe to notifications. The target object is ignorant of this. * 3. The event in C #. The delegate acts as an abstract observer interface, while the object that provides the event acts as the target object, and the delegate is a more loosely coupled design than the abstract observer interface. * * * Applicable scenario: * 1. When an abstract model has two facets, one aspect depends on the other. * encapsulate the two in separate objects so that they can be changed and reused independently of each other. * 2. When a change to an object needs to change other objects at the same time, it is not known how many objects need to be changed. * 3. When an object must notify other objects, it cannot assume that other objects are who. * In other words, you don't want these objects to be tightly coupled * http://www.diyibk.com/post/97.html
* * Design principles * Work hard for loosely coupled design between interacting objects;
Design mode-Observer mode