> 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