Java rich client design patterns: where to find?

Discussion in 'Java' started by diegomrosa, Mar 17, 2006.

  1. diegomrosa

    diegomrosa Guest

    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
     
    diegomrosa, Mar 17, 2006
    #1
    1. Advertising

  2. diegomrosa

    Oliver Wong Guest

    "diegomrosa" <> wrote in message
    news:...
    [snip]
    >
    > 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.
    >

    [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/02...f=pd_bbs_1/102-4704180-0024120?_encoding=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
     
    Oliver Wong, Mar 17, 2006
    #2
    1. Advertising

  3. diegomrosa

    diegomrosa Guest

    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
     
    diegomrosa, Mar 17, 2006
    #3
  4. diegomrosa

    Oliver Wong Guest

    "diegomrosa" <> wrote in message
    news:...
    > 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.


    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
     
    Oliver Wong, Mar 17, 2006
    #4
  5. diegomrosa

    Roedy Green Guest

    On 17 Mar 2006 10:05:06 -0800, "diegomrosa" <>
    wrote, quoted or indirectly quoted someone who said :

    >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
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 17, 2006
    #5
  6. diegomrosa

    diegomrosa Guest

    > 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
     
    diegomrosa, Mar 17, 2006
    #6
  7. diegomrosa

    Oliver Wong Guest

    "diegomrosa" <> wrote in message
    news:...
    >> 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).


    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
    >> 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!


    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
     
    Oliver Wong, Mar 17, 2006
    #7
  8. diegomrosa

    Chris Uppal Guest

    diegomrosa wrote:

    > 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
     
    Chris Uppal, Mar 18, 2006
    #8
  9. diegomrosa

    diegomrosa Guest

    diegomrosa, Mar 27, 2006
    #9
  10. diegomrosa

    hangstrap

    Joined:
    Sep 3, 2007
    Messages:
    1
    Hi Diego

    I am asking the exact same question that you are. Where can I find a good working example? IMHO one of the reasons that Swing has such a bad rap is because there is no standard framework.

    Two links that might help.

    http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html?page=1
    - I thought that too much logic eneded up in the view.

    and http://blog.hibernate.org/cgi-bin/blosxom.cgi/Christian%20Bauer/java/hibernateswing.html

    Neither of them are MVP but HMVC...


    Do you have any other examples for me?

    Richard
     
    hangstrap, Sep 3, 2007
    #10
  11. diegomrosa

    spae0022

    Joined:
    Dec 17, 2010
    Messages:
    1
    Swing MVP

    Hi guys,

    I know this thread is old, but thought I would make a comment. I've done a lot of Swing development and was quite frusterated with the lack of framework. There are so many options for Java EE, but not much out there for SE.

    This being the case, I took up the challenge of putting together a Java MVP framework that you can use with Swing. I outline the project in my blog on Java MVP - logicdevelopment.net/blog/?p=16 The project is called Biscotti. Really clean separation of model view presenter with some add-ins for people used to doing MVP on the web.
     
    spae0022, Dec 17, 2010
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike
    Replies:
    1
    Views:
    364
    Chris Smith
    Apr 7, 2004
  2. crichmon
    Replies:
    4
    Views:
    485
    Mabden
    Jul 7, 2004
  3. Tim Smith
    Replies:
    2
    Views:
    855
    Tim Smith
    Dec 15, 2004
  4. John
    Replies:
    0
    Views:
    596
  5. Hollow Quincy

    rich:dataTable - rich:dataScroller

    Hollow Quincy, Dec 30, 2011, in forum: Java
    Replies:
    5
    Views:
    4,547
    Arved Sandstrom
    Jan 2, 2012
Loading...

Share This Page