当前位置:首页 > 开发教程 >

Wikipedia, the free encyclopedia

时间:2013-04-26 15:13 来源:网络整理 作者:采集侠 收藏

Model–view–controller (MVC) is a software architecture pattern which separates the representation of information from the user's interaction with it. The model consists of application data, business rules, logic, and functions. A view ca

Model–view–controller (MVC) is a software architecture pattern which separates the representation of information from the user's interaction with it. The model consists of application data, business rules, logic, and functions. A view can be any output representation of data, such as a chart or a diagram. Multiple views of the same data are possible, such as a bar chart for management and a tabular view for accountants. The controller mediates input, converting it to commands for the model or view. The central ideas behind MVC are code reusability and separation of concerns.

Contents

[edit] Component interactions

Wikipedia, the free encyclopedia

Wikipedia, the free encyclopedia

A typical collaboration of the MVC components

In addition to dividing the application into three kinds of components, the MVC design defines the interactions between them.

[edit] Use in web applications

Although originally developed for personal computing, Model View Controller has been widely adapted as an architecture for World Wide Web applications in all major programming languages. Several commercial and noncommercial application frameworks have been created that enforce the pattern. These frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server.

Early web MVC frameworks took a thin client approach that placed almost the entire model, view and controller logic on the server. In this approach, the client sends either hyperlink requests or form input to the controller and then receives a complete and updated web page (or other document) from the view; the model exists entirely on the server. As client technologies have matured, frameworks such as and Backbone have been created that allow the MVC components to execute partly on the client (see also AJAX).

[edit] History

MVC was one of the seminal insights of the early field of graphical user interfaces, and one of the first works to describe and implement software constructs in terms of their responsibilities.

Trygve Reenskaug introduced MVC into Smalltalk-76 while visiting Xerox Parc, in the 70's; next, in the 80's, Jim Althoff and others implemented a version of MVC for the Smalltalk-80 class library. Only later MVC was expressed as a general concept, in an 1988 article.

This first MVC concept defined Controller as "the module that deals with input" (similarly to how the View deals with output). This definition has no place any more in a modern application, because its role is taken up by a combination of the View and the modern OSs and frameworks.

The Controller, in modern applications of 2000's, is a module, or an intermediary section of code, that mediates communication (between the Model and View) and unifies validation, using either direct calls or the Observer — to decouple the Model from the View in the active Model.

Other aspects of the MVC also evolved, but as a variant of the original concept, and because "parts of classic MVC don't really make sense for rich clients these days": HMVC, MVA, MVP, MVVM, and others that adapted MVC to different contexts.

[edit] See also [edit] References [edit] External links


开发教程阅读排行

最新文章