Presentation Patterns ASP NET MVC

0
22

The Model-View-Controller (MVC) pattern is a pattern used for separating presentation details from business domain details. The Model in the pattern is the business model / domain and the business logic of the system. The View is the presentation of the data and the user interface of the system. The View (V) generally speaks to the Model via the Controller, which is usually responsible for gathering data from the V, and interacting with or updating the Model, as well as updating the V (either the V can be explicitly notified that it must be updated by the controller, or will be notified of changes from the Model by following an Observer pattern).

There are different variations to the classic MVC pattern, namely Model2, Model-View-Presenter (MVP), and PresentationModel (also known as Model-View-View-Model or just ViewModel).

PresentationModel is a pattern used in desktop Windows WPF applications and so will not be discussed here.Although it is gaining traction as a pattern for Silverlight Rich Internet Applications (RIA's).

The two patterns for web development are Model2 and MVP.

In the classic MVC pattern, the User interacts with the View, the View notifies the Controller of the action, and the Controller updates the Model. The Model then updates the View via an Observer pattern – the View listens for notifications from the Model, and when the Model is changed, it notifies the View of the changes, allowing the View to update itself.

In the MVP pattern, the Presenter can be thought of as the Controller in classic MVC, however MVP is different to the classic MVC pattern in that it completely separates the View from the Model: the View can only speak to the Presenter, and the Model can only speak to the Presenter as well. There are two variations of the MVP pattern: Supervising Controller and Passive View. In Passive View, the View only ever receives notifications from the Presenter: it is the Presenter's responsibility to retrieve details from and send details to the View. In Supervising Controller, this responsibility is not as strict, in that the View may notify the Presenter of any changes to itself (usually through Data Binding).

Model2 is similar to the MVP pattern in that the View and Model are completely separate and only communicate through a Controller, however it also has the concept of a Front Controller. The Front Controller is what the View speaks to in Model2 – when a User interacts with a View, the View will interact with the Front Controller, which will determine which View the request came from, and to which Controller the request must be dispatched to fulfill the request, switching to different views if necessary.

Source

Leave a Reply