Difference between MVC & MVP

Introduction

Model-View-Controller (MVC) and Model-View-Presenter (MVP) patterns are used for quite a time by many developers/ architects for designing applications. Both (MVC & MVP) patterns have been used for several years and address a key OO principal namely separation of concerns between the UI and the business layers. One question that keeps coming up over and over again is: What are the differences between the two patterns? Surprisingly the answer is more complex than what you would suspect. Part of reasons I think many developers shy away from using either pattern is the confusion over the differences. Before we dig into the differences let’s examine how the patterns work and the key benefits to using either one.

Model View Controller (MVC) Pattern

Difference between MVC & MVP

The MVC pattern is a UI presentation pattern that focuses on separating the UI (View) from its business layer (Model). The pattern separates responsibilities across three components:

  • the view is responsible for rending UI elements
  • the controller is responsible for responding to UI actions
  • and the model is responsible for business behaviors and state management.

In most implementation, all three components can directly interact with each other and in some implementations, the controller is responsible for determining which view to display.

Model View Presenter (MVP) Pattern

4b65a-dp22

The MVP pattern is a UI presentation pattern based on the concepts of the MVC pattern. The pattern separates responsibilities across four components:

  • the view is responsible for rending UI elements
  • the view interface is used to loosely couple the presenter from its view
  • the presenter is responsible for interacting with the view/model
  • and the model is responsible for business behaviors and state management

In some implementations the, presenter interacts with a service (controller) layer to retrieve/persist the model. The view interface and service layer are commonly used to make writing unit tests for the presenter and the model easier.

Differences

the main difference between the two are as follows:MVC & MVP Diff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s