Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Observable/Observer

Thread view: 
Srikanth - 14 Nov 2005 06:53 GMT
Is there any difference in performance if we use ordinary call back
methods on indivisual objects separately instead of Observable/Observer
api.
I have an Observable class which has a single Observer, when there is
only one Observer is it worth using Observable/Observer api or is it
better to use a call nack method instead. Off course the design looks
better. But other than that is there any other difference?
Chris Smith - 14 Nov 2005 08:13 GMT
> Is there any difference in performance if we use ordinary call back
> methods on indivisual objects separately instead of Observable/Observer
> api.

> I have an Observable class which has a single Observer, when there is
> only one Observer is it worth using Observable/Observer api or is it
> better to use a call nack method instead. Off course the design looks
> better. But other than that is there any other difference?

There shouldn't be a significant difference in performance that I can
see.

By and large, though, use of Observable/Observer is very rare.  Because
it requires that you subclass the Observable class, it's not very clean,
easy to retro-fit into existing code, nor easy to refactor after it's
done.  For the most part, modern projects use the event listener idiom
instead, by declaring their own interfaces with callback methods.  See
Swing for plenty of examples.

Requiring a single listener is actually considered proper for the event
listener idiom, so you're in luck... if you are still worried about
keeping a list of listeners, you don't have to.  Just call your method
setXXXListener instead of addXXXListener.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Srikanth - 14 Nov 2005 09:29 GMT
Thanks Chris. :-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.