10.3. Constructing the MVP Application

Constructing the Model portion of the application is no different from the MVC model. The Model encompasses the domain model as well as the business logic and data access layer, if there is one. We won't go into detail about constructing the Model. Not only should it be fairly familiar, but there are many different strategies and patterns for constructing your Model that are independent of participation in an MVP application. You might choose a traditional OOD (Object Oriented Design) method, a Domain-Driven Design method, or possibly even a message-passing or SOA (Service Oriented Architecture) method. Any of these could be used successfully for building a user-centric application's Model.

The trickiest part of the MVP design process is the View. It must represent all of the interaction you will have with your user, using display-agnostic data types. The View, in essence, forms your application's contract with what is "on the glass" or visible to the user on their monitor. If you are following a TDD development process, your View is likely to change and evolve during the course of development, as requirements become more apparent. That should be easy to do if the proper separation between View and Presenter is maintained, although a little refactoring along the way never hurt anyone.

In most languages, it is easiest to represent your View as an interface. The concrete class directly responsible for display will implement the View interface. ...

Get Code Leader: Using People, Tools, and Processes to Build Successful Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.