• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Observer and Observable

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please give me a better idea about what these two classes do? (Yes, I am an OOP newbie, and no, I can't afford the latest whizz-bang book!
;-) ).
If possible, some code showing how they work will be even better, as I tend to grasp things a little better when I get to play with the code and see what works and what does not.
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Evan,
BTW - Observer is an interface rather than a class.
A class can implement an Observer interface when it wishes to tell other objects that some event of common interest is going to happen. Suppose, I am trying to write an online chat application and one of the condition is that every client that is connected to the chat server should be updated everytime any one says something.
So we might have Chat session to be an Observable and each client to be implementing Observer interface. So it lets you brodcast event notification to any number of interested clients.
Check out the further details here:

It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic