Java Forum / General / March 2006
Java rich client design patterns: where to find?
diegomrosa - 17 Mar 2006 18:22 GMT Hi all,
another possible title for this message would be:
Where can I find effective references on design patterns and best practices to build complete and elegant Swing applications?
I have been developing Swing applications for about 3 years and never got satisfied with the results. In the begining I was not using any design pattern, just putting all my code there in the same class, so you can imagine the mess. After some months I started looking for some references on "building elegant Swing applications" and what I found was very frustrating: there are very few _effective_ references on that.
I think _effective_ is a very important word here. In fact, there are thousands of sites and books describing Java technologies and another thousand others explaining how to build a complete Web application using J2EE technologies. The problem is finding references on building a complete, real-life, java rich client application. This topic is so controverse that one will find many terminologies to define the same type of application: java rich client application, java desktop application, java GUI application, Swing application. The situation gets worse by the fact that people used MVC to build Swing. Then you try googling "swing MVC" and thousands of sites explaining how Swing was developed show up. The problem is I DO NOT WANT TO KNOW HOW SWING WAS DEVELOPED, I WANT TO KNOW HOW TO DEVELOP GOOD APPLICATIONS USING SWING! I have even tried to adapt some J2EE patterns to Swing applications, but the results were definetly not good.
In fact, there are some sparse references describing how to build complete Swing applications using patterns like Presentation Model and Model-View-Presenter (MVP): - Desktop Java Live: http://www.sourcebeat.com/TitleAction.do?id=10 - JGoodies: www.jgoodies.com - Martin Fowler home-page: www.martinfowler.com - Martin Fowler work-in-progress (Patterns of Enterprise Application Architecture): www.martinfowler.com/eaaDev - Spring Rich Client Project: www.springframework.org/spring-rcp - Eclipse Rich Client Platform: wiki.eclipse.org/index.php/Rich_Client_Platform - The Humble Dialog Box: www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf
The problem with this references is that the information is either not uniform or not consistent. Each one explains MVP one way, with very poor examples. It would be very good to see a complete source code example of a Swing application using MVP and accessing a persistence layer. Does anybody know where can I find that? Any book talking about this topic would be very good too.
"It is our belief the only problem with Swing is that there are a limited number of higher-level abstractions available that assist in making the toolkit simpler and easier to use, and a limited number of design best practices. The goal of spring-richclient is to provide that." Spring Rich Client Project
Thanks in advance, Diego M. da Rosa diegomrosa at gmail dot com
Oliver Wong - 17 Mar 2006 18:51 GMT [snip]
> I think _effective_ is a very important word here. In fact, there are > thousands of sites and books describing Java technologies and another [quoted text clipped - 10 lines] > SWING! I have even tried to adapt some J2EE patterns to Swing > applications, but the results were definetly not good. [snip]
> The problem with this references is that the information is either not > uniform or not consistent. Each one explains MVP one way, with very > poor examples. It would be very good to see a complete source code > example of a Swing application using MVP and accessing a persistence > layer. Does anybody know where can I find that? Any book talking about > this topic would be very good too. Maybe go straight to the source? ISBN: 0201633612. http://www.amazon.com/gp/product/0201633612/sr=8-1/qid=1142617810/ref=pd_bbs_1/1 02-4704180-0024120?%5Fencoding=UTF8
This book only covers MVC though, not MVP. But after reading this book, you should be able to "get" what design patterns are all about, it won't be hard to learn new patterns (including MVP).
- Oliver
diegomrosa - 17 Mar 2006 19:05 GMT Thanks a lot for your answer Oliver, but I have already read this book (GoF) a couple of times. Believe me, I know what design patterns are all about. Now, how can I learn about the MVP design pattern if I can not find a single book describing it?
People, I am NOT searching references on: - General purpose design patterns; - J2EE design patterns; - Swing and MVC.
All I want is a Java rich client design patterns and best practices guide.
Diego
Oliver Wong - 17 Mar 2006 19:32 GMT > Thanks a lot for your answer Oliver, but I have already read this book > (GoF) a couple of times. Believe me, I know what design patterns are [quoted text clipped - 8 lines] > All I want is a Java rich client design patterns and best practices > guide. Well, I don't know of a book that is specifically about writing Java Rich Client applications using design patterns. You still gotta do some thinking yourself; if it were as easy as following a recipe in a book, you wouldn't need programmers, you'd just answer a few questions in a wizard, click "Ok", and out comes the application.
When I google for "Model View Presenter", the first hit I get is http://www.martinfowler.com/eaaDev/ModelViewPresenter.html which explains it pretty well, IMHO.
- Oliver
diegomrosa - 17 Mar 2006 20:06 GMT > Well, I don't know of a book that is specifically about writing Java > Rich Client applications using design patterns. You still gotta do some > thinking yourself; if it were as easy as following a recipe in a book, you > wouldn't need programmers, you'd just answer a few questions in a wizard, > click "Ok", and out comes the application. You can be sure that is not what I want! Take a look at the Spring Rich Client Project home-page and you will see that I am not the only person in the world concerned about that (see quotation in the end of the original message).
> When I google for "Model View Presenter", the first hit I get is > http://www.martinfowler.com/eaaDev/ModelViewPresenter.html which explains it > pretty well, IMHO. Well, you could have saved some time if you had copied this link from my original message. IMHO it is a very good text, but it is far from explaining it PRETTY well. The text is kind of superficial and the example used by Martin is extremelly simple. Have you ever tried writing a more complex application using this pattern? Well, I did and I think there are some issues uncovered. Martin says something about releasing this as a book and I hope it happens soon!
Diego
Oliver Wong - 17 Mar 2006 20:39 GMT >> Well, I don't know of a book that is specifically about writing Java >> Rich Client applications using design patterns. You still gotta do some [quoted text clipped - 7 lines] > in the world concerned about that (see quotation in the end of the > original message). Projects that start to drift away from J2SE and towards J2EE make my eyes glaze over, because they tend to get vague about what exactly they're useful for. From http://www.springframework.org/spring-rcp:
<quote> The goal of the Spring Rich Client Project (Spring Rich) is to provide a viable option for developers that need a platform and a 'best-practices' guide for constructing Swing applications quickly. </quote>
To which I reply:
<reply> Great. How does it accomplish that goal? By providing a JAR file I can download? By publishing a book with a list of best-practices? By sacrificing a goat on an altar to the good-code Gods? </reply>
AFAICS, there's no further information on the project, other than they simply "want" for it to be easier for developers, and that they don't plan on reinventing the wheel. They don't answer questions like "How is your way better than what I'm doing right now?" or even the more basic "Just what IS your way?" But I digress...
>> When I google for "Model View Presenter", the first hit I get is >> http://www.martinfowler.com/eaaDev/ModelViewPresenter.html which explains [quoted text clipped - 8 lines] > I think there are some issues uncovered. Martin says something about > releasing this as a book and I hope it happens soon! To be honest, I what Fowler calls "MVP", I call "MVC", and what Fowler calls "MVC", I call "a bad idea". From Fowler's page:
<quote> Classic MVC doesn't work well with modern rich client tools because they design things so that the view handles all the user events such as mouse and keyboard clicks. </quote>
The way I learned MVC, the controller actually handles the user events.
<quote> In Model View Presenter the view continues to handle these, but then immediately delegates these to the presenter. The presenter then decides what to do with the event, communicating with the domain and the data in the view's controls. </quote>
When I write MVC, I'm actually writing what Fowler calls MVP. Since my View is made up of the actual Swing widgets, yes, the View is "handling" the event, but it immediately delegates to my "Control" object, so conceptually, I'm thinking that my controller is the one... well... in control.
Finally, Fowler writes:
<quote> Another style of Model View Presenter allows the view to update itself from the model directly. In this case events are delegated from the view to the presenter, and the presenter updates the model as before. However instead of having the presenter update the view, the view draws its information directly from the model. This clearly simplifies the presenter and removes the need for the presenter to be dependent upon the view, or need an interface for manipulating the view. However the view now needs to have the logic to update itself fromt he model. </quote>
This is probably the closest to what I actually implement when I write MVC. The V directly queries the M to find out what to display, and the C "directly" (it may receive event notifications from the widgets, which are also part of V) manipulates the M.
So with the above clarification, I've written some moderately complex applications using the MVC/MVP design pattern, and I didn't encounter too many limitations or problems with it. Was there a specific problem that was unaddressed when you tried to apply this/these patterns to your application?
- Oliver
Roedy Green - 17 Mar 2006 19:52 GMT >Thanks a lot for your answer Oliver, but I have already read this book >(GoF) a couple of times. Believe me, I know what design patterns are >all about. Now, how can I learn about the MVP design pattern if I can >not find a single book describing it? for some other possibilities, see http://mindprod.com/jgloss/designpatterns.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Chris Uppal - 18 Mar 2006 11:51 GMT > All I want is a Java rich client design patterns and best practices > guide. Assuming that you are not looking for: - a guide to the best practises and/pr gotchas of Swing programming (e.g. being EDT-aware), - a guide to the best practises and/or gotchas of programming in general, - a guide to creating high-quality user interfaces, there doesn't seem to be much left to say:
+) Ensure that domain logic is separated from presentation logic.
+) Ensure that domain logic does not depend on any specific presentation.
+) (For bonus points) Ensure that presentation logic is composable rather than monolithic.
I don't do much Swing programming, but as far as I am aware it has little built-in architecural support for any of the above. OTOH, it has nothing much that /prevents/ the above either.
Borrowing the terminology of MVC (or MVP), and calling the domain-level stuff the model(s). One simple test for whether you've got good separation is whether you can easily start a new presentation on the same model, or tell an existing presentation to use a different model. Neither should take more than a line or two of extra code.
-- chris
diegomrosa - 27 Mar 2006 19:30 GMT For the ones who got curious about Spring Rich Client Project, there are some new documentation online (although a stable release is not available yet):
- Official Web Site: http://spring-rich-c.sourceforge.net/ - Wiki/docs: http://opensource.atlassian.com/confluence/spring/display/RCP/Home - Blog/tutorial: http://pa.rsons.org/node/6
It seems to be quite a comlete Java rich client/desktop framework.
> there doesn't seem to be much left to say: no comments.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|