Observer pattern

916 views

Published on

Observer pattern explained

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
916
On SlideShare
0
From Embeds
0
Number of Embeds
45
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Observer pattern

  1. 1. Observer PatternShahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/
  2. 2. Observer Defined• Hes a silent guardian. A watchful protector. A Dark Knight.
  3. 3. Pattern States Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
  4. 4. Applicability• When an abstraction has two aspects, one dependent on the other. Encapsulating these aspects in separate objects lets you vary and reuse them independently.• When a change to one object requires changing others, and you dont know how many objects need to be changed.• When an object should be able to notify other objects without making assumptions about who these objects are. In other words, you dont want these objects tightly coupled.
  5. 5. Observer @ Gotham City
  6. 6. Example (Notify on Withdrawal)
  7. 7. Subject
  8. 8. Concrete Subject
  9. 9. Observer
  10. 10. ConcreteObserverConcreteObserver
  11. 11. Invoke
  12. 12. Advantages1. Eliminates dependencies2. Increases extensibility3. Improves testability
  13. 13. Observer & .NET framework• Model View Controller Pattern - The observer pattern is used in the model view controller (MVC) architectural pattern. In MVC the this pattern is used to decouple the model from the view. View represents the Observer and the model is the Observable object.• The introduction of delegates and events provides a new and powerful means of implementing the Observer pattern

×