GWT MVP, Activities and Places Confusion

GWT MVP, Activities and Places Confusion

gwt development

As people start to dig into the real meat of GWT, they usually find themselves scratching their head about how to design their application.  All of the tutorials about GWT give good introduction applications to give a general idea of the concepts, but that is where they usually leave off.  Most people begin their confusion with the differences between the MVP pattern and GWT’s framework called Activities and Places.

The confusion seems to grow and grow until the person finds themselves utterly frustrated and posting on forums, or even worse, giving up completely.  Don’t let this happen to you!  The trick to demystifying these two concepts is understanding that they have ABSOLUTELY NOTHING to do with each other.  You may see them mentioned in the same article online or in the same tutorial, but that just muddies the water.

Think of them as two separate design patterns.  (Yeah, ok, Activities and Places is more of a framework, but just go with it.)  Just like the Gang of Four patterns can be used together, MVP and Activities and Places can be used side by side.

So what are they?  Glad you asked!

Model, View and Presenter

The model, view, presenter pattern is really not much more than an extension to the old behavioral pattern called model, view and controller from a few years back.  The idea is that there is a class (presenter) that specializes in tying the data (model) with the presentation of the data (view).  The presenter is also responsible for logic and control of other items as well.  This concept is best thought of as separation of concerns for a well designed GUI application. 

Activities and Places

GWT’s framework called Activies and Places is used for managing “bookmarkable pages” in a GWT application.  As you are well aware of, a GWT application is one single page with a whole slew of dynamic processing going on.  Historically, it was difficult to be able to bookmark a specific spot in your application and come back to it, that is what Activities and Places for you.  As you navigate through your application, you wi
Another side benefit to using Activities and Places is history management.  Due to the fact that Activities and Places work directly off of the browser’s URL, the browser’s back and forward button is auto-magically now part of your GWT application.  When the browser back button is clicked, the URL is changed which in turn makes changes to the state of your activities inside your application.ll see the URL of your application constantly changing.  These individual “bookmarkable links” let you jump into your application and pick right back up where you left off before.  The great part is that you don’t have to worry about coding the link part yourself, that is the responsibility of the framework. 

Two peas in a pod

I think the biggest source of confusion is that these two patterns/frameworks work very well in conjunction with each other.  Its kind of like chocolate and peanut butter, put them together and you have yummy goodness but it is hard to tell them apart once they are mixed.

Just remember that MVP is used for separation of concerns and Activies and Places is used for URL and history management.

Here is a great talk about the major concepts of GWT (who doesn’t love David Chandler?)

Technorati Tags: , , , , ,

Tags: , , , , ,

Leave a Comment