View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
OBSERVER The Observer defines a one to many relationship, so that when one object changes state, the others are notified and updated automatically. Some auctions demonstrate this pattern. Each bidder possesses a numbered paddle that is used to indicate a bid. The auctioneer starts the bidding, and "observes" when a paddle is raised to accept the bid. The acceptance of the bid changes the bid price, which is broadcast to all of the bidders in the form of a new bid
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Problem: How to handle a common side-effect (i.e. need to maintain consistency between related object)of partitioning a system into a collection of cooperating classes with out making the classes tightly coupled , - which in turn makes classes less reusable.
ConcreteSubject notifies its observers whenever a change occurs that could make its observers’ state inconsistent with its own.
After being informed of a change in the concrete subject, a ConcreteObserver object may query the subject for information. ConcreteObserver uses this information to reconcile its state with that of the subject.
Collaborations NOTE: How observer object that initiates the change request postpones its update until it gets a notification form the subject.