sasperilla wrote:
> Events in Actionscript are open.  Any class can send and receive
> events.  Swing is a closed model in that only Swing components can
> participate in the events.  Dispatching events into the event stream
> is as simple as calling dispatchEvent() in flash.  In Flex/Flash plain
> old Actionscript objects can participate in the event process.  ...
>
> This is a really important point because so often in Swing we'd use
> events in the UI and strange convoluted threading gymnastics to get
> back to the UI.  Just simply dispatching an event from the model layer
> would have been so much easier to notify the UI.
>   
Pardon me, but it looks to me that what you are describing as a Flex 
advantage, indeed it's a Flex limitation. First, it's not true that only 
Swing objects can participate to events: any object can implement any 
listener (and the trend is about using an universal type of event such 
as the PropertyChangeEvent), while you don't need anything special to 
fire events (you can compose with PropertyChangeSupport to avoid some 
boilerplate code). It's true that Swing needs some gymnastics with 
EventQueue.invokeLater() etc to deal with multi-threading, but AFAIK 
Flex doesn't need it because it is a single thread environment. While 
this can simplify things, it appears a sound limitation. Also, AFAIK 
most of the UI framework have this problem (that is, the graphic 
components aren't thread-safe) because of known theoretic design issues 
in doing them thread-safe, and have to resort to some gymnastic - the 
resulting boilerplate code can be less or more verbose in function of 
the programming language. For what concerns JavaFX, everything from Java 
applies, plus the binding mechanism that makes it event delivery even 
simpler.
> Event bubbling.  Flex/Flash has the concept of event bubbling.
> Bubbling helps alleviate the performance issues because events can be
> defined to bubble or not at event creation time.  Swing used to bubble
> all events in 1.0, but that got neutered when they had performance
> problems.  That was a serious mistake.  I think just introducing the
> concept of events that bubble or don't could have kept the old model
> around with the benefit of performance.
>
> Event bubbling allows outside clients to listen for possibly low level
> events from the outside without having to dig around inside a
> component to find the target. 
This has been discussed the past week about Oberon. I have yet to 
understand in a concrete case why this approach is useful - an external 
controller that is able to listen to an inner button event sounds very 
much as peeking its nose into some implementation details (why should it 
know that there's such button), that is bad separation of concerns. 
Certainly this could make implementation of UIs faster, but with many 
doubts about their design. It sounds as the old "faster vs better" - 
which doesn't mean that Flex is bad, but lead me to think that Flex is 
good for stuff that needs to be made quick and dirty, and with no long 
life. Can we elaborate on a concrete use case?
> Events use strings to uniquely identify themselves.  In Swing we used
> class types which meant we had to create special classes/interfaces to
> define different events that slows us down.  Reusing these pieces is
> confusing because we can't differentiate between two StateChanged
> events.  The event type string does this for you and is much faster
> than create yet another class.  While in Flash you can use separate
> Event classes for each type of event you don't have too.  You can
> reuse events or use DynamicEvent for a time saver.
>   
In Swing ActionEvent has got an actionCommand that can be used as a 
String identifier. Ok, not all events have got it. Still, I fear that 
"faster than writing a class" is a tradeoff with a better design. 
Impossible to say without a use case.

I had more comments about Flex vs Swing, but after reading better I 
understood you used them to tell us that JavaFX fixed these issues, so I 
won't comment on those.



-- 
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
[email protected] - mobile: +39 348.150.6941


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to