Re: Events-am I missing something?
Lew allegedly wrote:
What the OP has to learn is that there is magic in the event mechanism
and in event-driven architectures.
Daniele Futtorovic wrote:
Not "magic" in the sense the OP described. Nothing a Java programmer
couldn't build a replacement for if it were missing -- as opposed to,
f.i., Exception mechanisms.
Java doesn't have anything an assembly-language programmer couldn't build a
replacement for, either. That doesn't diminish the magic of Java a jot.
The point is that events and their handlers provide an elegant, effective
mechanism for certain solutions. Not that you couldn't do it some harder or
different way.
I very much agree with you that an event-driven architecture is lege
artis and powerful (and even beautiful), yet IMO it's more of a concept
Java allows you to implement fairly easily than much of a specific tool
Java provides you with.
Exactly, Event-driven programming is a powerful concept for which Java
provides support. That's a good thing.
Of course Java sports a lot of built-in event code, especially in GUI
libraries. If you write non-GUI, event-driven code, you might use
ChangeListeners or PropertyChangeListeners or others. But if you want to
write your own events, what parts of the JDK will you use? EventObject,
EventListener, EventListenerList, EventQueue. That's not a whole lot.
Java only has a couple of dozen keywords. That's not a whole lot, either, but
in no wise does that imply that Java is a weak tool. What is your point, exactly?
Java has the entire JavaBeans framework, which is built around event-driven
programming. You forgot to mention ActionListener, the various methods built
into the framework like addListener(), and the strength of having tutorials on
the subject, e.g.,
<http://java.sun.com/docs/books/tutorial/uiswing/events/index.html>
The question isn't whether it's "a whole lot", but whether it's useful, and
whether it's enough.
--
Lew