What are the Pros and Cons of an Observer Design Pattern

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 first registered listener is notified first or last. If you need to have cascading notifications, where object X must be notified first, followed by object Y, you must introduce an intermediary object to enforce the ordering.
  • The possibility of a memory leak: A reference tothe Observer is maintained by the Subject. Until the Subject releases the reference, the Observer cannot be removed by the garbage collector.