GWT MVP, Activities and Places Confusion
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
Activities and Places
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?)