The Model-View-Presenter pattern
The Model-View-Controller pattern gives us a better architecture for presenting data to the user. It assigns a specific task to each component so that possible changes might only concern one component letting the others unchanged. However, the three components of the MVC pattern remain someway interconnected: the View knows its Controller and the Model, and the Controller depends on the View and the Model. For example, a change to the Model may require changes to both the View and the Controller.
The Model-View-Presenter pattern or MVP proposes a layered architecture with fewer dependencies. In this pattern, the View intercepts the user interactions and asks the Presenter for changes to the Model. This means that the View does not directly interact with the Model, but acts on it through the Presenter. This eliminates any dependency between the View and the Model. The following image summarizes the pattern's architecture:
Let's look at how we can implement our...