• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Interface question

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i want to to use an interface to nofify from one class to another(both classes are unrelated) that a process has finished.
I would like to know if is possible to do that with an interface or if there is a better way to do it.

thanks in advance
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interface is a contract that says any implementing class must implement the methods defined in the interface. It can't include any code to actually send and receive messages.

That said, creating an interface to define the notification methods is a good idea. An interface is a nice abstraction. The JDK includes an Observer interface along with an Observable class that might do the job for you. Look into the JavaDoc and see if they'll fit.

Before I learned about Observable/Observer I wrote my own little pub-sub routine - a one-abstract-class-framework. If Observable doesn't work out for you I'd be happy to discuss my code. We usually don't hand out complete solutions in this forum - it's much more fun and educational if you work out the tricky bits yourself. So see what you can get going, post some code, we'll talk some more.
[ April 04, 2005: Message edited by: Stan James ]
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic