On Tuesday, June 7, 2011 3:05:10 PM UTC+2, Drew Spencer wrote:
>
> I was on your blog earlier Thomas and I did bookmark it :) , but I feel 
> like I need to learn MVP properly first. I managed to kinda adapt the first 
> MVP tutorial (
> http://code.google.com/webtoolkit/articles/mvp-architecture.html) to use 
> my objectify data, but I just hated the fact that i needed so many classes 
> to do something so simple - a class for every event, and a handler. Just 
> seems ridiculous.


I agree, but MVP is not about this eventing, it's only about decoupling the 
"presentation logic" (presenter; which in GWT you'd want to *not* depend on 
widgets or anything "GWT.create()d" so you can unit-test it with "plain 
Java", without the need for the sluggish GWTTestCase) from the view 
(widgets).
Have a look at the second tutorial rather than the first; much less verbose. 
Compared to the first, it transfers a bit of "logic" to the view but it's 
really worth it!
The thing is: you have a Presenter class that depends on a View interface, 
and a ViewImpl class implementing View and talking back to its presenter 
through a Delegate interface (you can replace View with Display, and/or 
Delegate with Presenter, choose your naming convention), implemented by the 
Presenter class (technically speaking, the Delegate interface is not 
required though). And keep in mind that what matters is that you can 
unit-test your presenter without the need for a GWTTestCase; that way you 
can use tools like EasyMock or Mockito to mock your dependencies (the View 
of course, but also GWT-RPC or RequestFactory services, or even the 
EventBus).
Besides unit-testing, MVP helps making clean code, because the code is split 
across two classes (with an interface in between for decoupling).
 

> I've just downloaded the gwtp plugin and looked at the demo project, and it 
> is a really heavy framework as you say. I really got away from php to avoid 
> frameworks so I would like to use the GWT stuff if possible.
>
> The thing I don't really get is that google says "GWT 2.1 introduces a 
> built-in framework for MVP development. This article looks at Activities and 
> Places in GWT 2.1, which relate to the presenter and view aspects of MVP." 
> With 
> that said, how can you say they have not much to do with MVP?
>

Well, go back read my blog: did I talk a single time about "model", "view" 
or "presenter" when explaining places and activities? An Activity can be a 
Composite widget (passing itself to the AcceptsOneWidget received in the 
start() method) and there wouldn't be MVP involved, or at least the Activity 
wouldn't be the presenter (because MVP can be implemented in different ways: 
Cell widgets actually do use MVP internally for instance).
The GWT team is also trying a new pattern where presenters are separate from 
activities (that's in the mobilewebapp sample, but they only scratched the 
surface).
There's no "one way" of doing MVP.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/aVZCYTJ0WS1zNnNK.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to