Callback VS listener

Is callback and listener same?
[37 byte] By [jimmy6a] at [2007-10-2 6:09:32]
# 1
Yes, a Listener is "called back" when a certain event has occured.Of course a Listener must be registered at an event source first if it wants to be called back.kind regards,Jos
JosAHa at 2007-7-16 13:10:08 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

> Yes, a Listener is "called back" when a certain event

> has occured.

> Of course a Listener must be registered at an event

> source first if it

> wants to be called back.

Please Mr. Fake Intimacy, don't dip into things you don't understand.

In design patterns you use the Command pattern as a replacement for procedural call-backs

> kind regards,

>

> Jos

And zip up please, everybody's already seen your willy.

.u....j.a at 2007-7-16 13:10:08 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
> In design patterns you use the Command pattern as a> replacement for procedural call-backsSure, but that wasn't what the OP asked: the OP wanted to know whetheror not a Listener can be interpreted as a call-back. And it can.kind regards,Jos
JosAHa at 2007-7-16 13:10:08 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

Jos:

The OP asked if they are the same, not if a listener could be interpreted as a callback. Those are two very different questions.

> Is callback and listener same?

No they are not the same. In the context of Java, a listener is a bundle of callbacks. For example, WindowListener is a bundle of seven callbacks for events related to a window. It would be more appropriate to say that a listener uses a callback or bundle of callbacks to "listen" for events. This does not make a listener itself a callback and it certainly doesn't make a callback a listener. This is better known as the Observer (or publish subscribe) pattern where one or more objects called observers (or listeners) may be registered on another object (called source/subject) to observe an event that the source might raise.

kablaira at 2007-7-16 13:10:08 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

> No they are not the same. In the context of Java, a listener is a

> bundle of callbacks. For example, WindowListener is a bundle of

> seven callbacks for events related to a window.

You're right; I forgot about those multiple method Listeners, I just

thought of ActionListeners and other simple (single method) Listeners.

The latter are simply callbacks, your example certainly is a bundle

of callbacks.

kind regards,

Jos

JosAHa at 2007-7-16 13:10:09 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
i know already. callback = command = observerable.listener = observer. Am i correct?
jimmy6a at 2007-7-16 13:10:09 > top of Java-index,Other Topics,Patterns & OO Design...