design-pattern-or-observer-pattern

What are the pros and cons of an Observer design pattern

Post Views: 5 PROS:                                                 Loose coupling between Subject and Observer: The subject knows only a list of observers, that implementthe Observer interface, it does no know the concrete implementation of the Observer. Broadcast communication: An eventnotification is broadcast to observers irrespective of the number of Observers CONS:                                                If not used carefullythe observer pattern can add unnecessary complexity. The order of Observer notifications is undependable. Simply registering the observers in a particular order will not enforce their order ofnotification. You don’t necessarily know if the…

Read More

Can you list some Java interfaces that use the observerdesign pattern

Post Views: 2 The Java Message Service (JMS) models the observer pattern, with its guaranteed delivery, non-local distribution, and persistence, to name a few of its benefits. The JMS publish-subscribe messaging model allows any number of subscribers to listen to topics of interest. When a message for the published topic is produced, all the associated subscribers are notified. The Java Foundation Classes (JFC) like JList, JTree and the JTable components manipulate data through their respective data models. The components act…

Read More

What is an observer design pattern

Post Views: 1 The Observer pattern is a behavioral design pattern that  allows an object (an Observer) to watch another object (a Subject). The subject and observer to have a publish/subscribe relationship. Observers can register to receive events from the Subject. Some of the practical uses of observer pattern are: When a change to one object requires changing of others, and you don’t know how many objects need to be changed. When an object should be able to notify other…

Read More