MVC模型

MVC模型

來自wiki翻譯了半天,發(fā)現(xiàn)有人早就翻譯了伶授,但是略有不同彰檬。后來看到阮一峰的關(guān)于mvc的說明,他說東西一般都很清楚谎砾,什么時(shí)候才能有他那樣的本事啊逢倍。
寒冬 http://www.cnblogs.com/winter-cn/p/4285171.html

總感覺自己對于controller和view的界限有點(diǎn)模糊。
MVC是針對有用戶交互的軟件架構(gòu)模式景图,它分成三個(gè)部分较雕,model,view,controller。

Components 組成

The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface.The model directly manages the data, logic and rules of the application.

模型(Model)是MVC的主要組件挚币,捕獲在問題領(lǐng)域的應(yīng)用程序的行為亮蒋,與用戶界面獨(dú)立。模型直接管理應(yīng)用的數(shù)據(jù)妆毕,邏輯慎玖,規(guī)則。

A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants.

視圖(View)可以是信息的任何輸出笛粘,比如chart或者diagram趁怔。同樣信息具有多個(gè)視圖是可能的,比如管理層的條形圖和會計(jì)人員的表格視圖薪前。

The third part, the controller, accepts input and converts it to commands for the model or view.

第三部分是控制器(controller),接受輸入润努,將之轉(zhuǎn)化為模型和視圖的命令。

Interactions交互

In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.

除了將應(yīng)用劃分成三個(gè)不同的組件示括,mvc設(shè)計(jì)還定義了他們之間的交互铺浇。

A model stores data that is retrieved according to commands from the controller and displayed in the view.

模型從控制器的命令檢索存儲的數(shù)據(jù)并展示給視圖層。

A view generates new output to the user based on changes in the model.

視圖基于模型的改變輸出新的內(nèi)容垛膝。

A controller can send commands to the model to update the model's state (e.g. editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g. by scrolling through a document).

控制層向模型發(fā)送命令鳍侣,更新模型的狀態(tài)(比如編輯文檔),它同樣能向相關(guān)聯(lián)的視圖發(fā)送命令來改變視圖的展示(比如文檔滾動(dòng))


圖片來自wiki

Use in web applications Web應(yīng)用的使用

Although originally developed for desktop computing, model–view–controller has been widely adopted as an architecture for World Wide Web applications in major programming languages. Several commercial and noncommercial web frameworkshave been created that enforce the pattern. These software frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server.

雖然最先是從桌面系統(tǒng)發(fā)展出來的丁稀,但是mvc的架構(gòu)被互聯(lián)網(wǎng)應(yīng)用廣泛地接受,一些商業(yè)和非商業(yè)的網(wǎng)絡(luò)框架采用了這個(gè)模式。他們在解釋上有些不同倚聚,主要是將mvc的責(zé)任劃分為客戶端和服務(wù)器端线衫。

Early web MVC frameworks took a [thin client]
(https://en.wikipedia.org/wiki/Thin_client) approach that placed almost the entire model, view and controller logic on the server. This is still reflected in popular frameworks such as Ruby on Rails, Django, ASP.NET MVC and Express. 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.

早期的mvc框架采用“瘦客戶端”的方法將整個(gè)模型,視圖秉沼,控制邏輯都放在了服務(wù)器端桶雀,這個(gè)反應(yīng)在了類似 Ruby on Rails,Django,ASP.net MVC 以及Express上面矿酵。 在這些方法中唬复,客戶端發(fā)送整個(gè)超鏈接請求或者表單輸入給控制層然后為視圖提供接收整個(gè)或者重新更新的網(wǎng)頁(或者其他文檔),模型完全存在于服務(wù)器全肮。

As client technologies have matured, frameworks such as AngularJS, EmberJS, JavaScriptMVC and Backbone have been created that allow the MVC components to execute partly on the client (also see Ajax).

當(dāng)客戶端的技術(shù)成熟的時(shí)候敞咧,類似AngularJS、EmberJS辜腺、JavascriptMVC休建、Backbone等創(chuàng)建了允許MVC部分在客戶端執(zhí)行的框架(參見Ajax).

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市评疗,隨后出現(xiàn)的幾起案子测砂,更是在濱河造成了極大的恐慌,老刑警劉巖百匆,帶你破解...
    沈念sama閱讀 216,651評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件砌些,死亡現(xiàn)場離奇詭異,居然都是意外死亡加匈,警方通過查閱死者的電腦和手機(jī)存璃,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,468評論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來雕拼,“玉大人纵东,你說我怎么就攤上這事∩犊埽” “怎么了偎球?”我有些...
    開封第一講書人閱讀 162,931評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長辑甜。 經(jīng)常有香客問我甜橱,道長,這世上最難降的妖魔是什么栈戳? 我笑而不...
    開封第一講書人閱讀 58,218評論 1 292
  • 正文 為了忘掉前任岂傲,我火速辦了婚禮,結(jié)果婚禮上子檀,老公的妹妹穿的比我還像新娘镊掖。我一直安慰自己乃戈,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,234評論 6 388
  • 文/花漫 我一把揭開白布亩进。 她就那樣靜靜地躺著症虑,像睡著了一般。 火紅的嫁衣襯著肌膚如雪归薛。 梳的紋絲不亂的頭發(fā)上谍憔,一...
    開封第一講書人閱讀 51,198評論 1 299
  • 那天,我揣著相機(jī)與錄音主籍,去河邊找鬼习贫。 笑死,一個(gè)胖子當(dāng)著我的面吹牛千元,可吹牛的內(nèi)容都是我干的苫昌。 我是一名探鬼主播,決...
    沈念sama閱讀 40,084評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼幸海,長吁一口氣:“原來是場噩夢啊……” “哼祟身!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起物独,我...
    開封第一講書人閱讀 38,926評論 0 274
  • 序言:老撾萬榮一對情侶失蹤袜硫,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后挡篓,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體婉陷,經(jīng)...
    沈念sama閱讀 45,341評論 1 311
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,563評論 2 333
  • 正文 我和宋清朗相戀三年瞻凤,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了憨攒。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,731評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡阀参,死狀恐怖肝集,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情蛛壳,我是刑警寧澤杏瞻,帶...
    沈念sama閱讀 35,430評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站衙荐,受9級特大地震影響捞挥,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜忧吟,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,036評論 3 326
  • 文/蒙蒙 一砌函、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦讹俊、人聲如沸垦沉。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,676評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽厕倍。三九已至,卻和暖如春贩疙,著一層夾襖步出監(jiān)牢的瞬間讹弯,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,829評論 1 269
  • 我被黑心中介騙來泰國打工这溅, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留组民,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,743評論 2 368
  • 正文 我出身青樓芍躏,卻偏偏與公主長得像邪乍,于是被迫代替她去往敵國和親降狠。 傳聞我的和親對象是個(gè)殘疾皇子对竣,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,629評論 2 354

推薦閱讀更多精彩內(nèi)容