Curriculum design patterns Design patterns observer mode to explain succinctly 21-1


1 The course explains

1.1 Type:

1.2 Definitions:

1.3 application scenarios:

1.4 Advantages:

1.5 Disadvantages:

 

 

 


1 The course explains
1.1 Type:

Behavioral

 

1.2 Definitions:

Define: Define the many dependencies between objects, objects allow multiple viewers simultaneously monitor a particular topic subject, when the subject is the object changes, it's all dependents (observers) are notified and updated

 

For example:

A micro-channel circle of friends issued a state, B and C commented, D and comment time, ABC can receive reminders circle of friends. Here is the observed dynamic circle of friends (theme objects), review of all accounts is an observer.

Taobao some good shoes, a lot of people point the price notification button. When the price of shoes, people of all price points notification of the account will receive an alert. Here is the observed price of the shoes, people all price points account notifications are observers.

 

 

1.3 application scenarios:

◆ related behavior scene, to establish a trigger mechanism

 

 

1.4 Advantages:

◆ established between the observer and observed an abstract coupling (increasing both the observer and observed easily extended)
◆ support broadcast communication mode observer

 

1.5 Disadvantages:

There are too many details between the observer-dependent, time consuming and increase the complexity of the program

◆ To use properly, to avoid the cycle call (between the observer and the observed circulation to avoid, in order to avoid an infinite loop resulting in a system crash)

 

 

Guess you like

Origin www.cnblogs.com/1446358788-qq/p/12318881.html