I know its a Gregg Bolinger topic, but as we have Java-gui-book author here, I might ask this question again. I have much more problems with developing gui-clients than putting together some dhtml pages connected by some flow organized through some kind of a servlet-controller (be it with framework like struts or webworks2 or not). My gui clients allways end up in some messy bloated collection of business calls, gui-widgeds definition, layout-management things, some thread-management stuff and even some state-holding variables. This is difficult to understand next day. O.k. I factor business logic to business objects. I do allready know and use observer pattern. But there must be a better way. Rob, you know some book, website or even open-Source project, which you consider as a good example for inteligent separation of concerns in a gui app?
regards Axel [ July 08, 2004: Message edited by: Axel Janssen ]
I have the exact same problem -- I know of the Mediator pattern, for example, but my GUIs always (well, I've only written a couple of small "personal" apps) end up being a jungle. So, I would also love to hear about any helpful resources. I think I asked the same question a couple of months back when a Swing author was promoting but we got no answers back then ( looks like my this week's question will end up the same way )
<a href="http://www.amazon.com/exec/obidos/ASIN/0201310058/radikal" target="_blank" rel="nofollow">Effective Java Programming Language Guide</a> - probably the best book ever written for intermediate to advanced java programmers!
I haven't seen a book dedicated to this topic, although many of the patterns books talk about it. One thing I've found is that if I at least design, and (even better) implement a command line interface for my GUI programs, the separation stays much cleaner. Besides, then the Unix folks love you
I realize that this won't work in every situation, but is more applicable than it might appear at first blush. For example, you might think this suggestion utterly inapplicable for an image editing program, but think about many of the functions an image editing program must perform. Convert among image formats? You can write a CLI for that. Apply some sort of effect to an image? You can write a CLI for that.
The trick, or course, is to make sure you're not writing two separate programs, and cutting and pasting code between them. Make sure you're using the same engine in both, and the interfaces (GUI and CLI) are just asking for and receiving input.
This is a Gregg Bolinger topic. I think one reason why there is no definative answer to this question is because Sun has not provided one. They made the API, they should specify the correct patterns for building Swing apps. But as of yet, they have not.
There are appearntly developers who know what they are doing. I mean, look at IDEA and Netbeans. These are very robust responsive pure Swing driven applications. It would be nice if someone wrote a book on this topic though.
Just yesterday I was thinking about an internal training I'm arranging with a coworker of mine -- one for which we need a codebase to play with, preferably "tuned" to the particular training's purposes. Well, we came up with a couple of ideas for a standalone Swing application and I started to remember all those problems I'd had with my previous attempts at clean Swing code. Guess what -- I also thought about just starting out with a command-line interface! (although I did abandon the idea as too "absurd"...) Now, I think I'm going to try and see what that approach leads to.