Sunday, May 9, 2010

GWT MVP, blending stuff: presenter, dispatch, gin, guice, tests, maven

Lately, GWT is being considered one of the best alternatives to produce large client side web applications. Maybe, the main reason to this is the use of patterns like Model-View-Presenter (MVP), EventBus, Command-Pattern, etc, which makes the Gwt development really easy and fast.
These rules and best practices were presented by Ray Ryan at last Google I/O, and the main consecuence was the growth of nice libraries which incredibly help you to produce huge Gwt applications.

Unfortunately there is not good documentation nor examples to learn how to blend all these components in your project. Taking the project Hupa as a reference, I have re-factored the Google Contacts MVP project in order to show how to integrate gwt-presenter, gwt-dispatch, google-gin and google-guice. I have coded JRE tests covering all the presenters, and GWT tests to demonstrate that views and RPCs can also be tested with functional tests. I have put everything in a project handled with maven and eclipse.

I prepared this work to my last Gwt presentation and it is shared in google code:

svn checkout
mvn clean test gwt:run package

The main reason to adopt this patterns is the ability to tests almost the code of your application in the JVM. This report in Hudson demonstrate that almost everything can be tested in GWT.