Model–view–presenter, Backbone.js
Model–view–presenter
Model–view–presenter (MVP) is a derivation of the model–view–controller (MVC) architectural pattern, and is used mostly for building user interfaces.
In MVP the presenter assumes the functionality of the "middle-man". In MVP, all presentation logic is pushed to the presenter.[1]
Contents
[hide]Pattern description[edit]
MVP is a user interface architectural pattern engineered to facilitate automated unit testing and improve the separation of concerns in presentation logic:
- The model is an interface defining the data to be displayed or otherwise acted upon in the user interface.
- The view is a passive interface that displays data (the model) and routes user commands (events) to the presenter to act upon that data.
- The presenter acts upon the model and the view. It retrieves data from repositories (the model), and formats it for display in the view.
Normally, the view implementation instantiates the concrete presenter object, providing a reference to itself. The following C# code demonstrates a simple view constructor, where ConcreteDomainPresenterimplements the IDomainPresenter interface:
public class DomainView : IDomainView
{
private IDomainPresenter domainPresenter = null;
///<summary>Constructor</summary>
public DomainView()
{
domainPresenter = new ConcreteDomainPresenter(this);
}
}
The degree of logic permitted in the view varies among different implementations. At one extreme, the view is entirely passive, forwarding all interaction operations to the presenter. In this formulation, when a user triggers an event method of the view, it does nothing but invoke a method of the presenter that has no parameters and no return value. The presenter then retrieves data from the view through methods defined by the view interface. Finally, the presenter operates on the model and updates the view with the results of the operation. Other versions of model-view-presenter allow some latitude with respect to which class handles a particular interaction, event, or command. This is often more suitable for web-based architectures, where the view, which executes on a client's browser, may be the best place to handle a particular interaction or command.
From a layering point of view, the presenter class might be considered as belonging to the application layer in a multilayered architecture system, but it can also be seen as a presenter layer of its own between the application layer and the user interface layer.
Implementation in .NET[edit]
The .NET environment supports the MVP pattern much like any other development environment. The same model and presenter class can be used to support multiple interfaces, such as an ASP.NET Web application, a Windows Forms application, or a Silverlight application. The presenter gets and sets information from/to the view through an interface that can be accessed by the interface (view) component.
In addition to manually implementing the pattern, a model-view-presenter framework may be used to support the MVP pattern in a more automated fashion. Below is a list of such frameworks under the .NET platform.
.NET frameworks[edit]
- Claymore
- MVC# Framework
- Web Client Software Factory
- Evolution.Net MVP Framework
- ASP.NET Web Forms Model-View-Presenter (MVP)
- Nucleo.NET
- WinForms MVP
Implementation in Java[edit]
In a Java (AWT/Swing/SWT) application, the MVP pattern can be used by letting the user interface class implement a view interface.
The same approach can be used for Java web-based applications, since modern Java component-based Web frameworks allow development of client-side logic using the same component approach as thick clients.
Implementing MVP in Google Web Toolkit requires only that some component implement the view interface. The same approach is possible using the Echo2 Web framework.
MVP can be implemented in Java SE (AWT and Swing) applications using the Biscotti and MVP4J frameworks.
Java frameworks[edit]
Implementation in PHP[edit]
As of PHP's flexible runtime environment, there are wide possibilities of approaches of an application logic. A great example of MVP pattern implementation is Nette Framework implementing rich presenter layer and view layer through templating system Latte (web template engine). Implementation of model layer is left on the end application programmer.
PHP frameworks[edit]
History[edit]
The model-view-presenter software pattern originated in the early 1990s at Taligent, a joint venture of Apple, HP, and IBM, and was the underlying programming model for application development in Taligent'sC++-based CommonPoint environment. The pattern was later migrated by Taligent to Java and popularized in a paper by Taligent CTO Mike Potel.[3] After Taligent's demise in 1997, Andy Bower and Blair McGlashan of Dolphin Smalltalk adapted the MVP pattern to form the basis for their Smalltalk user interface framework.[4] In 2006, Microsoft began incorporating MVP into their documentation and examples for user interface programming in the .NET framework.[5][6] The evolution and multiple variants of the MVP pattern, including the relationship of MVP to other design patterns such as MVC, is discussed in detail in an article by Martin Fowler[7] and another by Derek Greer[8]
See also[edit]
- Common layers in an information system logical architecture
- Model–view–controller
- Model View ViewModel
- Presenter First
References[edit]
- ^ https://developers.google.com/web-toolkit/articles/testing_methodologies_using_gwt
- ^ Large scale application development and MVP from GWT project's web site. It explains how to use MVP within GWT.
- ^ "MVP: Model-View-Presenter. The Taligent Programming Model for C++ and Java." Mike Potel
- ^ "Twisting the Triad. The evolution of the Dolphin Smalltalk MVP application framework." Andy Bower, Blair McGlashan
- ^ "Model View Presenter." Jean-Paul Boodhoo, MSDN Magazine, August 2006
- ^ "The Model-View-Presenter (MVP) Pattern." Microsoft Developer Network
- ^ "GUI Architectures" Martin Fowler
- ^ "Interactive Application Architecture Patterns" Derek Greer
External links[edit]
source - https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter
Backbone.js
Developer(s) | Jeremy Ashkenas |
---|---|
Initial release | October 13, 2010 |
Stable release | 1.2.0 / May 13, 2015[1] |
Development status | Active |
Written in | JavaScript |
Operating system | Cross-platform |
Size | 7.3 KB production 69 KB development |
Type | JavaScript library |
License | MIT |
Website | backbonejs |
Backbone.js is a JavaScript library with a RESTful JSON interface and is based on the model–view–presenter (MVP) application design paradigm. Backbone is known for being lightweight, as its only dependency is on one JavaScript library,[2] Underscore.js. It is designed for developing single-page web applications,[3] and for keeping various parts of web applications (e.g. multiple clients and the server) synchronized.[4] Backbone was created by Jeremy Ashkenas, who is also known forCoffeeScript.[5]
Use[edit]
This section needs additional citations for verification. (November 2013) |
The following web applications are built with Backbone.js[6]:
- Airbnb [7]
- BitTorrent.com
- Diaspora [7]
- Digg [8]
- DocumentCloud [7]
- Flixster
- Foursquare [7]
- Grooveshark [7]
- Groupon Now [7]
- Hulu [7]
- LinkedIn Mobile
- NewsBlur [9]
- Openbravo Mobile (with Enyo).[10]
- Pandora Radio [7]
- Sony Entertainment Network
- Soundcloud [7]
- Strideapp [7]
- The Climate Corporation
- Trello [7]
- USA Today.com [7]
- WordPress.com [7]
- xTuple (with Enyo).[11]
References[edit]
- ^ Change Log
- ^ Alex MacCaw (18 August 2011). JavaScript Web Applications. O'Reilly Media, Inc. p. 165. ISBN 978-1-4493-0351-8. Retrieved 27 April 2012.
- ^ "What SendHub Learned Building a Single-Page Backbone.js App", ReadWriteWeb
- ^ "Behind the rumours: how we built our Twitter riots interactive", The Guardian (London), 8 December 2011
- ^ Stenger, Brad (April 4, 2012), "JavaScript Meetup City", Open (The New York Times)
- ^ Companies and Websites using Backbone.js
- ^ ab c d e f g h i j k l m Example Sites Which Use Backbone.js
- ^ http://www.fastcolabs.com/3014663/open-company/inside-the-tech-stack-digg-used-to-replace-google-reader
- ^ Backbonification: migrating a large JavaScript project from DOM spaghetti to Backbone.js, Samuel Clay (NewsBlur) 13th November 2012
- ^ "Mobile UI Components". Retrieved 2014-03-22.
- ^ "A Shorter Letter". Retrieved 2014-03-22.
Further reading[edit]
- Osmani, Addy (March 22, 2013). Developing Backbone.js Applications (1st ed.). O'Reilly Media. p. 150. ISBN 978-1449328252.
External links[edit]
source - https://en.wikipedia.org/wiki/Backbone.js