Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a Observer Pattern in a Application .

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Simply, the Observer pattern allows one object (the observer) to watch another (the subject)."

Can anybody please in what cases we need to Observe an Object ?

My question is what is the need to use an Observer Pattern?

Thanks in advance.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typically the Observer pattern would be used in a Publisher-Subscriber situation. The observer pattern allows you to reduce coupling between the subscriber and publisher by reducing the knowledge each class must have about the other.
The publisher (subject) exposes a method by which subscribers (object) can register/de-register with it. This allows the publisher to maintain a list of subscribers without actually knowing their implementation - This is just a gist...

You can read more here.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sam , it was a good answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic