Successfully reported this slideshow.

Observer Pattern

861 views

Published on

  • Be the first to comment

  • Be the first to like this

Observer Pattern

  1. 1. Observer Pattern<br />Albert Guo<br />junyuo@gmail.com<br />1<br />
  2. 2. Motivation<br />Intent<br />Implementation<br />Applicability & Examples<br />Agenda<br />2<br />
  3. 3. Let's assume we have a stock system which provides data for several types of client. We want to have a client implemented as a web based application but in near future we need to add clients for mobile devices, Palm or Pocket PC, or to have a system to notify the users with sms alerts. Now it's simple to see what we need from the observer pattern: we need to separate the subject(stocks server) from it's observers(client applications) in such a way that adding new observer will be transparent for the server.<br />Motivation<br />3<br />
  4. 4. Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.<br />Intent<br />4<br />
  5. 5. Implementation<br />5<br />
  6. 6. 6<br />Implementation – cont.<br />
  7. 7. 7<br />Applicability & Examples<br />
  8. 8. 8<br />Applicability & Examples – cont.<br />
  9. 9. 9<br />Applicability & Examples – cont.<br />
  10. 10. 10<br />Applicability & Examples – cont.<br />
  11. 11. 11<br />Applicability & Examples – cont.<br />
  12. 12. 12<br />Applicability & Examples – cont.<br />
  13. 13. 13<br />Applicability & Examples – cont.<br />Email Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌<br />SMS Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌<br />RSS Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌<br />----------------------------------------------------<br />Email Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關<br />SMS Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關<br />RSS Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關<br />---------------------------------------------------<br />

×