2

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?

Nikolay Shabak
  • 576
  • 1
  • 7
  • 18

1 Answers1

1

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.

mawalker
  • 2,072
  • 2
  • 22
  • 34
  • What I often do is just write the model/presenter, and leave the view up to someone else ... let those 'artsy' people "make things look good", hehe. – mawalker Dec 24 '15 at 12:29
  • Also, MVP allows you to get rid of view implementation details and implement platform-agnostic business logic both for models and presenters. For example, I have implemented an application that can work using the same business logic both on Android and GWT (even using Java 8 on both platforms): the core is usually an `app` lib, and the implementations are `app-android` and `app-gwt` (and sometimes even more, like CLI, Swing, JavaFX) that only specify the views on the target platforms and merely bootstrap the concrete application lifecycle. – Lyubomyr Shaydariv Dec 24 '15 at 13:38