I have read on MVP tutorial of GWT project site that, view should only contain event handlers for widgets it contain and logic for handling them should reside in presenter. Regarding this i have below doubts :
Many times we need to dynamically change the style of widgets on the basis of events received on view, so does it make sense to move this kind of logic in prsenter ?
Many times we need to get data from several fields in view and create a object and pass it to some widget, like a cellTable, which has its own asyncDataProvider. So does it make sense in creating getters and setters for all view fields, so that presenter can access them and form object and initialize the cellTable and pass object into it ? Is it a good idea to add widgets in view's panels in presenter ?
Everywhere I read that reason for adding logic to presenter instead of view is to increase jUnit test coverage,which saves time. But, as far as I can see, we can use mocking frameworks on View as well to write test cases for basic logic inside them.
Considering point 3, does it really make sense to write so much of code(getters/ setters) in view. I believe that flow should go back to presenter from view, only when :
a. we need to switch views
b. we don't have data to be shown in view, so presenter can provide it via RPC
For starters, please see the Demystifying MVP and EventBus in GWT ( slides ) presentation from Google IO 2013. It's an update to the whole MVP + GWT approach which should answer some of your doubts and questions.
Generally, there are many opinions and approaches when it comes to MVP and designing the architecture of your application. So, YMMV.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.