Observer Pattern

  • 646 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
646
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
11
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Observer Pattern
    Albert Guo
    junyuo@gmail.com
    1
  • 2. Motivation
    Intent
    Implementation
    Applicability & Examples
    Agenda
    2
  • 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.
    Motivation
    3
  • 4. Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
    Intent
    4
  • 5. Implementation
    5
  • 6. 6
    Implementation – cont.
  • 7. 7
    Applicability & Examples
  • 8. 8
    Applicability & Examples – cont.
  • 9. 9
    Applicability & Examples – cont.
  • 10. 10
    Applicability & Examples – cont.
  • 11. 11
    Applicability & Examples – cont.
  • 12. 12
    Applicability & Examples – cont.
  • 13. 13
    Applicability & Examples – cont.
    Email Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌
    SMS Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌
    RSS Subscriber: 《集中市場》三大法人賣超79億元,法說會績優股力抗國際崩跌
    ----------------------------------------------------
    Email Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關
    SMS Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關
    RSS Subscriber: 台股盤後-鴻家軍登高力抗希臘債信危機 開低拉高力守8000關
    ---------------------------------------------------