Note 3- head first design pattern observer pattern: Beverage Starbuzz

The principle of openness: class should be open for extension, but closed for modification.

  - Part blog in the observer mode, by adding a new observer, we can extend the theme at any time (Subject), and do not need to add code to the topic.

  - Decorator Pattern is also in full compliance with the principle of openness.

 

Decorator Pattern: dynamically responsibility attached to the object. To extend the functionality, decorated to provide a more flexible than inheritance alternative.

to be continued

Guess you like

Origin www.cnblogs.com/xy-ouyang/p/11427188.html