Tuesday, August 25th, 2009

Be your company MVP with GWT!

Category: Articles, GWT

<p>Sorry about the cheesy title, I couldn’t resist. In one of those moods I guess. Chris Lowe has posted a detailed example of a new-age GWT application that uses lots of cool tech based on Ray Ryans talk on MVP pattern;
  • Use a command pattern;
  • Use an Event Bus (a.k.a Event Collaboration);
  • Use Dependency Injection.
  • Chris takes these ideas and applies them to the starter project created by the Google plugin for Eclipse. To get this done, he uses a slew of libraries:

    GWT-Presenter An implementation of the MVP pattern;
    GWT-Dispatch An implementation of the command pattern;
    Google Gin Dependency Injection based on Google’s Guice;
    GWT-Log A log4j-style logger for GWT.

    NOTE: currently GIN needs to be built from source using SVN/Ant.

    You’ll also need the following libraries at the server:

    log4j A logging framework;
    Google Guice 2.0 A dependency injection framework for Java.

    Then, the tutorial walks you through setting up your views, presenters, and events. It is Java, so you will notice a fair amount of source code (but at least the GuiceServlet gets rid of most of the XML). Just joshing with ya!

    It was cool to see my buddy Rob’s Customware being the place that created some of the key libraries. Good on ya mate!

    Related Content:

    Posted by Dion Almaer at 6:14 am
    12 Comments

    ++---
    2.7 rating from 42 votes

    12 Comments »

    Comments feed TrackBack URI

    Small post bug: The Google Code MVP-link is missing a ” in the anchor tag.

    Comment by ErikT — August 25, 2009

    Good god what a mess, do people really develop stuff this way?

    Comment by rubley — August 25, 2009

    That article should get an award for the most over engineered, code extensive Hello World example ever made. No thanks, I’ll stick to JSP and AJAX.

    Comment by Stakka — August 25, 2009

    I couldn’t agree more with Stakka, this piece of code is just a gas factory and making an hello world example of it was definitely a bad idea…

    Comment by SleepyCod — August 25, 2009

    Lol, fail.

    Comment by Darkimmortal — August 25, 2009

    GWT is great but I’m still confused of MVP concept

    visit: ecofe.blogspot.com

    Comment by coffeehunter — August 26, 2009

    I just watched the presentation and read the article and had to sign up here just to agree with Stakka and Darkimmortal: hello world fail, lol

    Comment by krycek — August 26, 2009

    @Critics: This is not a “HelloWorld”-Sample, this is supposed to be an example for writing HUGE GWT applications á la Google Wave.

    If you measure by “HelloWorld”-standards, even Rails is overkill for their famous 15-minute-blog-sample.

    Comment by BonoboBoner — August 26, 2009

    @BonoboBoner: We understand it’s skeleton code for a larger project, requiring a bit larger initial code. But if this pattern requires this much code, spread across so many files, it must be a nightmare to maintain as a project grows.

    Comment by Stakka — August 26, 2009

    The stack you’ve mention is not the best one inspired by the video. MVP4G (http://code.google.com/p/mvp4g/) is a better implementation of MVP/DI/Events ideas expressed during the talk.

    Comment by Oleks — August 27, 2009

    @Stakka: “spread across so many files, it must be a nightmare to maintain as a project grows.”

    Actually it is easier to maintain (at least that was my impression after porting my helloworld-style-spaghetti-code to a structured MVP-approach), since your widgets know nothing about data access for example. When trying to swap out a GWT-Tree with a TreePanel from GXT for example, you can leave the RPC as it is and just have to register a different event source for selection of tree-items, etc. It is far easier to unit-test as well.

    Comment by BonoboBoner — August 27, 2009

    I agree with Oleks. The example really needs to have sufficient complexity to support the idioms being expressed. Although this example (http://code.google.com/webtoolkit/doc/latest/tutorial/mvp-architecture.html) does not show all the elements (it is missing GIN, command pattern, and a few others), it does present a “simple as possible” example of how to use MVP and event bus along with introductory unit test setup. I would like to know if anyone has seen a solid implementation of the command pattern anywhere. I would like to use that pattern in my upcoming GWT app. thanks in advance.

    Comment by jorel — April 16, 2010

    Leave a comment

    You must be logged in to post a comment.