Thursday, November 13, 2008

Model-View-Presenter (MVP)

The MVP pattern resolves the depedency created between Model and View in MVC pattern. MVP uses a Presenter which provides a 2 way communication between the Model and View.
Execution Events:
1. Presenter passes calls from View(User Interaction) to Model, and
2. Presenter receives update events from Model, to update the View.

MVP pattern improves testability, as all the logic and processing occurs within the Presenter, but it does add some complexity to the implementation because updates must pass from the Presenter to the View.

Model-View-Controller (MVC)

The Model-View-Controller (MVC) Patterns improve reusability of business logic by separating the three components required to generate and manage a specific user interface (such as a single Web page).

Model - contains the data

View (the Web page) - will display and allow the user to manipulate
Controller - links the Model and the View, and manages all interaction and processing of the data in the Model

Execution Events:

1. User interaction with the View raises events in the Controller

2. The Model then raises events to update the View

However, this introduces a dependency between the Model and the View. To avoid this, the MVP pattern uses a Presenter that both updates the Model and receives update events from it, using these updates to update the View.

ASP.NET Patterns

Building websites has been a great attraction and fun to play with for many , though many follow some kind of coding practices without able to reason why we follow such standards in our web development.

The following post helps you to understand the basic ASP.NET patterns that can be followed for building simple - well modularised - easily maintainable Applications.

Basic Design Patterns and Groups
Design patterns fall into groups, based on the type and aims of the pattern.
For example, some patterns provide presentation logic for displaying specific views that make up the user interface. Others control the way that the application behaves as the user interacts with it.

There are also groups of patterns that specify techniques for persisting data, define best practices for data access, and indicate optimum approaches for creating instances of objects that the application uses. The following list shows some of the most common design patterns within these groups:
  • Host or Behavioral
    1. Command
    2. Publish-Subscribe / Observer
    3. Plug-in / Module / Intercepting Filter
  • Structural
    1. Service Agent / Proxy / Broker
    2. Provider / Adapter
  • Creational
    1. Factory / Builder / Injection
    2. Singleton
  • Persistence
    1. Repository