Nikolay Shabak
Nikolay Shabak

Reputation: 606

Why should I use MVP pattern in GWTP application?

I've implemented such an architecture for two times, so haven't realised real profits it gives.

All I obtained is code of View, separated in two places. Most of the methods contain lines of code like getView().* In additional there are at least two additional entities: class *Presenter and interface *UiHandler

Do I something wrong?

Upvotes: 2

Views: 85

Answers (1)

mawalker
mawalker

Reputation: 2070

I can't speak about GTWP but the MVP Pattern (wiki link) In general has a 'model' (your data) a 'view' (the UI, etc.) and a 'presenter' (the logic that binds the two together.) (which you know)

MVP is a user interface architectural pattern engineered to facilitate automated unit testing and improve the separation of concerns in presentation logic:

Separating those concerns and allowing automated unit testing is where MVP shines. You can stub in the Presenter and test both the model and the view. This allows you to develop those in a more TDD way. Especially since you should already have well defined interface between all the components.

Another bonus of this is that you can easily 'swap' view impl. as long as they impl. the interface properly.

So if you design your MVP to have 'view' only have the UI parts, and the 'model' to have the data parts, then the 'presenter' only has to have the logic parts where it can 'ignore' the 'specifics' of the view's & model's impls.

Upvotes: 1

Related Questions