Model-View-Presenter with Google Web Toolkit (GWT)

2019-08-14 16:19发布

问题:

I am thinking about developing a new application using web toolkit. I decided that the best option is going to be to use the Model-View-Presenter Design Pattern. After doing plenty of research, I found two different ways of implementing the skeleton code. (I am still trying to learn MVP and how to best utilize the disjunction between the model and the view)

Here are the two links discussing GWT MVP

https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces https://developers.google.com/web-toolkit/articles/mvp-architecture

I read through and understand all the information in the second link, how you associate presenters with views, and how you have your custom events and such. I really like this because this means that several developers will be able to work on the project I have in mind.

However, the first link, also points out some interesting stuff, mostly using XML and @UiBinder and other things. I feel that those will not be necessary for this particular application but I want to make sure I have not overlooked anything.

Basically - How good of a programming practice is the style the style in the second link (the one with presenters for each view)

Thank you

回答1:

You should be not be comparing MVPActivitiesAndPlaces and MVP . If browser history management is not your concern use only MVP.

  1. Activities And Places are not mandatory for MVP. They only allow you clean browser history management which integrates nicely with MVP architecture.

  2. UiBinder is not mandatory for MVP. They can be used with MVP.

  3. The MVP design paradigm mostly is driven with Unit testing as main driver and to keep out slow running GWTTestCase out as much as possible.

At the heart of this pattern is the separation of functionality into components that logically make sense, but in the case of GWT there is a clear focus on making the view as simple as possible in order to minimize our reliance on GWTTestCase and reduce the overall time spent running tests.



标签: gwt mvp gwt-mvp