I read the chapter two of Head first design pattern just now,next ,i will just make a record.
This chapter tells us how to use the observer pattern.after read it ,i realized that the
observer pattern is very important and usefull to us .now i will sum it up .
The observer pattern is used in the following condition.when our system contains a
one -to- many dependency between objects,what'more,it is necessary that the change of
one object 'state will make all of the dependents notified and updataed.here is the formal
definition of the observer pattern:The observer pattern defines a one-to-may dependency
among objects so that when one object changes state,all of its dependents are notified
and updataed automatically.
Next,i will sum up the characters of the observer pattern.the subject part,the abstract
observer,the concrete subject and the concrete observer.
This pattern shows up server oo design principles.here are they .
1 indentify the aspects of your app that vary and separate them from what stays the
same . in the pattern,what vary are the state of the subject and the number of the observer.
with this pattern,the things vary are well encapsulated.
2 programe to interface ,not to implementation.
3 favor composition than inheritance.