0

Tell me about observer pattern and its use case. I watched youtube video but didn't get. please someone explain it briefly.when , where and how we can use observer design pattern?

  • Possible duplicate of [When should we use Observer and Observable](http://stackoverflow.com/questions/13744450/when-should-we-use-observer-and-observable) – jaco0646 Mar 13 '17 at 15:00

2 Answers2

1

It can be used for event listeners. For example, when user presses certain button, objects listening to that event can be notified using observer pattern.

Karol Musolff
  • 46
  • 1
  • 7
1

A classical example are GUIs. Usually, you design your GUI and register some elements like buttons in a listener/observer. You may do this in one class. If you click a button on your GUI, it will notify/fire an action to the listener/observer. In another class, which implements the observable interface you can define functions for the specific notifications.

ndueck
  • 713
  • 1
  • 8
  • 27