> [...]
> I've been searching for a complete & complex example application with
> good design, from which I could learn & realize my mistakes, but
> couldn't find any through google so far... [...]
Martin Fowler describes desktop patterns that I found useful
for working with Swing, especially "Presentation Model" and
the Model-View-Presenter (MVP) variants, and a bunch of other
less important patterns such as Presentation Chooser or
Event Aggregator.
Martin motivates these patterns and why one would separate
the presentation logic from the presentation in a longer text.
Just google for "Organizing Presentation Logic".
I provide presentations that describe the architecture
of the JGoodies tools and demos. These slides complement
Fowlers texts and pattern descriptions; my focus is on
the concrete Swing implementation.
My favorite pattern for Swing is "Presentation Model",
because Swing already includes a good portion of the
synchronization necessary for using this pattern.
The free JGoodies Binding tutorial contains source
code examples for using "Presentation Model" with Swing.
And so you can get the following for free: Fowlers motivation,
and his pattern catalog, my slides with additional diagrams,
smaller Swing source code examples. My presentations are here:
http://www.jgoodies.com/articles/
-Karsten
unomystEz - 02 Sep 2006 15:41 GMT
Karsten,
I looked at your presentations and they are very good, thanks. What
about when dealing with extremely high performance GUI applications
that have a lot of complexity at the model layer, enough to warrant
writing a custom event dispatch/firing mechanism - as opposed to using
the built-in Java dispatching. ie, consider a stock application that
monitors 2000 stocks and stock prices can change very often, in total
maybe 40 updates a second a realized, then up to 30 swing components
per stock needs to be notified which could result in a lot of firing
and handling per second. What are your thoughts on this?
> > [...]
> > I've been searching for a complete & complex example application with
[quoted text clipped - 27 lines]
>
> -Karsten
Karsten Lentzsch - 03 Sep 2006 12:14 GMT
> [...] What
> about when dealing with extremely high performance GUI applications
> that have a lot of complexity at the model layer, [...] in total
> maybe 40 updates a second a realized, then up to 30 swing components
> per stock needs to be notified which could result in a lot of firing
> and handling per second. What are your thoughts on this?
Repainting costs more than firing and listening to events.
If performance is critical, identify the hot spots that
consume the time, and I guess it'll be drawing and potentially
revalidation of the views. Check the standard tricks to
improving the painting performance: invalidate only necessary
portions, honor the clipping rectangle, consider using
a customized repaint manager.
Two years ago I worked with apps that fired and observed
10 times more events than are handled by my recent code.
(Before 1.0 the JGoodies Binding lacked the BeanAdapter)
Reducing the number of events and handlers did result
in no perceived performance improvements. The motivation
for reducing the number of events and handlers was debugging.
If you have more concerns about performance, you may
post at the forums at javadesktop.org. It seems to me
that the audience is larger there, and that you get
feedback from AWT/Swing team members there.
-Karsten