I’ve been using the MVP pattern for a new project and have developed an open-source framework (available here).  I’m not an MVP expert, but I’ve learned a lot about the pattern and UI patterns at a whole.  One important idea about the pattern that I’ve learned is to ensure that the layers are properly separated.  For instance, some of the errors that happen in the framework happen because the proper separation of concerns is violated, which can lead to a harder-to-maintain application, bugs, or application errors.  A good understanding of this separation is important.

The presenter itself is responsible for:

 

  • computational logic generated by business rules
  • validation rules that fire across the domain to ensure some business rule related to other data in the database is in a correct state
  • loading of data that the view will use
  • communicating with other presenters

 

The view itself is responsible for:

 

  • Binding model data to the UI
  • Managing the UI

 

There are some gray areas to evaluate, such as the following:

  • Should the view request data from the presenter via an event?
  • Should the view be reactive to the existence of data in the model, or should code to bind to the view fire after an event happens?