10.2. What Is MVP?
Many developers are familiar with the Model-View-Controller (MVC) model, which has long been popular for building UI-based applications. In the MVC model, pains are taken to separate the application into three distinct layers.
Model — The lowest layer of the application that represents the domain model and what is traditionally regarded as "business logic"
View — the UI portion, containing input fields, buttons, and other user interface elements, but no business logic
Controller — The controller's job is to take information from the model and push it into the view, and to take input supplied by the user from the view and pass it to the model for processing.
In practice, the controller can't do everything, and in some cases, there is direct interaction between the model and the view, as well as interactions mediated by the controller. The controller is concerned primarily with data exchange, pushing user input down, but the view often directly accesses the model for display purposes. The components form a triangular relationship, as shown in Figure 10-1.
Figure 10-1. Figure 10-1
In a .NET desktop application, for example, the Windows Form–derived class that represents a single form is playing the part of both View and Controller because the form typically contains not only the user interface elements, but also event-handling methods that receive events from the ...
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.