9
votes

I've been looking into GWT and MVP recently and to be honest I'm very confused. My project will include around 40 different places or views all together. While reading multiple tutorials, some follow Model-View-Presenter and others use Activities and Places, all under the subject of MVP, GWT.

I'm not sure what to follow for a new MVP, GWT 2.2 project.

Many thanks, Alex

6
You don't have to choose: activities and places have actually nothing to do with MVP (they're all and only about navigation and loose coupling). So just use both (i.e. build your activities as presenters, as pohl says in his answer)Thomas Broyer

6 Answers

5
votes

Alex,

Activities and Places are Google's implementation of the MVP framework. There are many well established additional MVP frameworks for GWT which encompass many additional features not yet incorporated into GWT. The two I would recommend are:

GWT Platform: http://code.google.com/p/gwt-platform/

MVP4G: http://code.google.com/p/mvp4g/

They have many additional features to reduce the amount of boilerplate code you have to write to implement solutions. They are worth a peak before choosing Google's A&P.

Cheers Gene

4
votes

Activities and Places is the MVP solution that was implemented in GWT 2.2. Before that, MVP was only a recommended approach without an official framework provided by Google. That's why you're getting confused.

I would recommend you to stick with Activities and Places, since it's the official Google solution for MVP.

I hope it helps.

3
votes

It turns out that an Activity takes the role of a Presenter in the MVP design pattern. Not all of your presenters need to be Activities, but if you have an Activity you can think of it as being a special kind of Presenter with a well-defined lifecycle used for transitions from one "place" to another.

So it's not a choice between MVP and "activities & places". Rather, they're all of the same idea. The new activities & places framework is just a refinement.

2
votes

Alex,

Activities and Places (as well as ActivityMapper and more) are classes which the GWT team provided to formalize their earlier MVP pattern recommendations. Some time ago I've tried the "raw" MVP recommendations and am currently using the higher-level approach the aforementioned classes provide. It certainly feels easier to use the new classes. In addition to a nice MVP abstraction, you get the important aspect of handling browser history navigation in your application practically for free.

The MVP API is here to stay, it seems, so if you're using GWT 2.2.x I'd also recommend utilizing the new MVP classes from the inception of your project.

2
votes

Activities and Places are not a MVP framework! Google removes this "disturbance" in later docs. it is just a browser history framework (to easily (de)serialize state of the app). but on implementing MVP and using A&P it turns out that in many cases it is a good idea to merge activity and presenter.

in a more general case one activity could start n presenters.

0
votes

We used activities and places along with presenters in our design. We also used MVP.

The setup was a view, viewImpl, and inside the view interface, if needed, was a presenter interface that was also declared. The view interface was a pass through to the viewImpl implementation class. The activity went to the viewImpl based on it's business logic and in our case, the viewImpl went to a stand-alone composite widget.

If it was needed, the composite widget used a presenter to get back (another pass through) to the activity. No business logic was in the view or the viewImpl by the way, that was only in the activity. It worked well!