20 January, 2008


This post explains the basic concepts and differences between MVC and MVP design patterns. Read the recommended links to gain more insights on MVC, MVP and related concepts.

The MVC design pattern separates (read "loosely couple") the presentation layer (View) from the data layer (Model); while the processing logic is contained in the Controller class. Multiple Views can be supported by a single Model via the intelligent Controller.

Now, the MVP design pattern (a MVC upgrade) provides better capabilities. It uses a Presenter (similar to Controller in MVC) to update the View through an interface. Here, only the Presenter interacts with the Model and makes it fully independent of the View.

The big difference between MVP and MVC is that with MVP, the View is completely controlled by the Presenter, whereas in the MVC, the Controller and the Model can update the view. Consequently, MVP provides more loose coupling and easier unit testing than MVC, since the Presenter interacts with the View via an interface.One should choose (and customize) between the two patterns based on application requirement. Major factors that would influence this decision are performance, extensibility and maintainability.

Recommended links
1) Read all about the
MVC Design Pattern.
2) Gain in-depth knowledge on
MVP Design Pattern.
3) Read this excellent
article by Todd Snyder where the difference between MVC and MVP is illustrated succinctly.
4) Billy McCafferty's
blog explores the two flavors of MVP (Passive and Supervising Controller) coined by Martin Fowler.
5) Aviad Ezra provides an interesting
view on MVP.

No comments: