計算機(jī) 外文翻譯 外文文獻(xiàn) 英文文獻(xiàn)及譯文一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架——MVC_第1頁
計算機(jī) 外文翻譯 外文文獻(xiàn) 英文文獻(xiàn)及譯文一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架——MVC_第2頁
計算機(jī) 外文翻譯 外文文獻(xiàn) 英文文獻(xiàn)及譯文一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架——MVC_第3頁
計算機(jī) 外文翻譯 外文文獻(xiàn) 英文文獻(xiàn)及譯文一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架——MVC_第4頁
計算機(jī) 外文翻譯 外文文獻(xiàn) 英文文獻(xiàn)及譯文一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架——MVC_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、譯文一:一種新的網(wǎng)絡(luò)應(yīng)用程序開發(fā)框架mvc* luo guangchun, the ph.d. of uest of china; wang yanhua, the master of the uest of china; lu xianliang, the professor of uest of china, advisor of ph.d.; han hong, the ph.d. of uest of china摘要 mvc(model/view/controller)的設(shè)計模式出現(xiàn)在在smalltalk-80,并在軟件的設(shè)計中廣泛應(yīng)用。本文介紹一種基于mvc框架的的新網(wǎng)絡(luò)應(yīng)用程序。這

2、種框架把實(shí)施邏輯與表現(xiàn)形式獨(dú)立開來。它也提高了系統(tǒng)的可維護(hù)性,可擴(kuò)展性以及使用模塊數(shù)據(jù)庫備案、模板數(shù)據(jù)庫,通訊對象和緩沖隊列的性能。關(guān)鍵詞:mvc、設(shè)計模式、網(wǎng)絡(luò)應(yīng)用程序1.簡介 網(wǎng)絡(luò)應(yīng)用系統(tǒng)是一個基于b(rowser)/ s(erver)模型應(yīng)用系統(tǒng)。它利用多種動態(tài)網(wǎng)頁開發(fā)技術(shù)。目前,軟件設(shè)計的主題之一是網(wǎng)絡(luò)應(yīng)用開發(fā)模式和工具的。它們直接影響系統(tǒng)的幾個關(guān)鍵因素,比如可維護(hù)性、可擴(kuò)展性、穩(wěn)定性和安全性。本文中,基于mvc1的網(wǎng)絡(luò)應(yīng)用程序的設(shè)計模式是為解決這兩類因素擴(kuò)展性和可維護(hù)性這些不易處理的問題。把mvc設(shè)計模式引入網(wǎng)絡(luò)應(yīng)用程序開發(fā),執(zhí)行邏輯可以獨(dú)立于系統(tǒng)的表現(xiàn)形式。 mvc由三種對象組成。

3、1)模型:是應(yīng)用對象,2)視圖:是它的屏幕的顯示,3)控制器:定義用戶界面并對輸入的信息做出響應(yīng)。在出現(xiàn)mvc之前,用戶界面的設(shè)計傾向于把這些東西做在一起。然而,mvc獨(dú)立了它們,增加系統(tǒng)的靈活性和可重用性。mvc把視圖和模型獨(dú)立開來,在它們之間建立了“subscribe/notify”協(xié)議。一個視圖必須確保其正確反映模型的狀態(tài)。每當(dāng)模型的數(shù)據(jù)發(fā)生改變,視圖會得到相應(yīng)的通知。作為回應(yīng),每個視圖都會有更新自身的機(jī)會。這個方法可以讓你附上一個模型的多個視圖以便提供不同的報告。你也可以不改變原模型同時創(chuàng)建新的視圖。2.背景和存在的問題 雖然mvc的設(shè)計模式已經(jīng)在smalltalk-80中提出了,并廣

4、泛應(yīng)用于軟件設(shè)計,介紹它到網(wǎng)頁應(yīng)用程序開發(fā)卻仍很困難的。主要由于以下兩個因素:1)首先,很難獨(dú)立 來自html的編程語言。早期的cgi程序使用字符串輸出創(chuàng)造了html內(nèi)容。默認(rèn)的,將html文本分成幾份,然后把他們嵌入到cgi程序中。腳本語言出現(xiàn)后,變成了腳本語言編寫的程序嵌入到html文本中。然而,這兩種方法有一個共同的不足,使他們不能完全獨(dú)立于html文本。因此,這兩種方法使采用mvc分離三層模式十分難以實(shí)現(xiàn)。2)第二,腳本語言的功能太弱。他們?nèi)狈σ恍┍匾募夹g(shù)支持來采用mvc的設(shè)計模式,如消息機(jī)制和事件回應(yīng)機(jī)制。直到j(luò)sp model2版,這種情況并沒有受到任何改善。依靠強(qiáng)大的java語

5、言功能,jsp model24某種程度上實(shí)行mvc設(shè)計理念。圖 1顯示了mvc的機(jī)制:模型(數(shù)據(jù)層):它是封裝到企業(yè)javabean。視圖(表示層):jsp負(fù)責(zé)的網(wǎng)頁方式,如報告的格式,分頁等??刂破?控制層):servlet受到網(wǎng)頁上的用戶的輸入并執(zhí)行有關(guān)的操作(呼叫相應(yīng)的ejb組件),給出了相關(guān)視圖,所以jsp會呈現(xiàn)這些結(jié)果。 jsp model2機(jī)制主要滿足了開發(fā)商對要求web應(yīng)用邏輯和用戶界面獨(dú)立的需求。但制仍然存在某些限,例如,盡管jsp model2已經(jīng)實(shí)施采用mvc設(shè)計模式的基本理念,三個層次之間的相互關(guān)系(servlet,java bean/ ejb和jsp)仍然封閉。特別是,

6、就servlet當(dāng)控制器,不僅控制選擇同時響應(yīng)模型的模塊,還負(fù)責(zé)對處理jsp轉(zhuǎn)移數(shù)據(jù)提供模塊。因為這一過程,servlet本身已實(shí)現(xiàn)非常復(fù)雜的執(zhí)行邏輯,對于體系的發(fā)展和維護(hù)這是正是一個棘手的問題。因此,在下面的網(wǎng)絡(luò)應(yīng)用系統(tǒng)框架,我們會進(jìn)一步劃分出功能的控制器。3.解決方案 圖2中顯示,這一系統(tǒng)框架包含三個內(nèi)核控制對象/類(syscontroller, model center, and lpm(logical page module) center)和它們的核心數(shù)據(jù)庫(system description database, model database, and lpm database)。

7、這三個控制對象/類根據(jù)原始的控制器劃分。通過這些控制對象/類和數(shù)據(jù)庫,下文將解釋部分的設(shè)計思想和該系統(tǒng)框架的實(shí)現(xiàn)機(jī)制。 首先,我們考慮syscontroller和系統(tǒng)的描述數(shù)據(jù)庫。他們負(fù)責(zé)接收用戶的要求和根據(jù)這些請求搜索有關(guān)的執(zhí)行邏輯。系統(tǒng)描述數(shù)據(jù)庫可以是一個xml2文件或一套xml文件。這個數(shù)據(jù)庫描述了不同的執(zhí)行邏輯與不同的用戶請求。執(zhí)行邏輯主要包括互動模式、數(shù)據(jù)來源與異常處理等,這些組織在一個樹形結(jié)構(gòu)中。而syscontroller可以搜索系統(tǒng)描述數(shù)據(jù)庫。它結(jié)合了用戶的要求和來自數(shù)據(jù)的執(zhí)行邏輯,然后把它們交給傳輸器來封裝。syscontroller有兩種方法搜索數(shù)據(jù)庫。 其一是使用dom對

8、象(document object model)3。當(dāng)應(yīng)用程序系統(tǒng)開機(jī),這樣需要dom解析器分析整個數(shù)據(jù)庫備案后載入內(nèi)存。數(shù)據(jù)庫將保留在內(nèi)存中的dom樹結(jié)構(gòu)。另一種是使用sax(simple api for xml)接口。兩者有各自的優(yōu)缺點(diǎn)。使用dom可以實(shí)現(xiàn)結(jié)構(gòu)搜索。它可以在大型數(shù)據(jù)庫上使用,但是會暫用更多的系統(tǒng)資源。而sax接口以高效率和更少的系統(tǒng)資源占用率著稱。唯一的缺點(diǎn)是它獲得信息比dom難。 其次,我們考慮模型中心和模型數(shù)據(jù)庫。該層通過調(diào)用給定模塊完成定義執(zhí)行邏輯。模型數(shù)據(jù)庫包括大量的對象和模塊。這些對象和模塊根據(jù)特定的執(zhí)行邏輯封裝響應(yīng)方法。當(dāng)模式中心接收到的執(zhí)行消息,它根據(jù)封裝在信

9、息里的執(zhí)行邏輯選擇合適的對象或模塊。然后按照給定的數(shù)據(jù)格式封裝模塊,冰傳輸給lpm中心。此外,每個對象或模塊只需要關(guān)心如何實(shí)現(xiàn)給定的事務(wù)的邏輯以及如何獲得必要的數(shù)據(jù)而不提交這些數(shù)據(jù)。 最后,我們研究一下lpm中心和lpm數(shù)據(jù)庫。lpm是實(shí)施描述的某一種數(shù)據(jù)類型的項目集合,它可以當(dāng)成是一個或一組磁盤文件。在另一方面,有一個網(wǎng)頁可有一個邏輯頁或多條邏輯頁。一個lpm的功能是很簡單的:它只需要在沒有被得到執(zhí)行邏輯和原數(shù)據(jù)內(nèi)容的情況下給定數(shù)據(jù)類型。因此事實(shí)上,lpm是作為標(biāo)簽庫(jsp)或數(shù)據(jù)捆綁(.net)而開發(fā)的。此外,這種類型的服務(wù)器腳本可以很容易由客戶開發(fā)人員在ui(user interfac

10、e)設(shè)計階段理解,what-you-see-is-what-you-get(所見即所得)工具也很容易開發(fā)。在這部分,lpm中心從模型中心收到數(shù)據(jù)。它根據(jù)給定數(shù)據(jù)類型和執(zhí)行邏輯選擇適當(dāng)?shù)倪壿嬳撃K,然后封裝邏輯頁的輸出模塊到http響應(yīng)并將發(fā)布到客戶端。注意到這3個控制對象,除了syscontroller,另外兩個不是直接進(jìn)入自己的核心數(shù)據(jù)庫。例如,模式中心不直接從模型數(shù)據(jù)庫調(diào)用對象或模塊。它實(shí)現(xiàn)了通過modelfactory的存取。(過程見圖2) 通過分析系統(tǒng)框架,可以看出整個系統(tǒng)完全符合mvc設(shè)計模式。在在系統(tǒng)的開發(fā)時期各部分的開發(fā)者三者冰不具有相互的干涉。當(dāng)系統(tǒng)框架已確定,各部分驚人的發(fā)現(xiàn)

11、開發(fā)的相似。在過去這對網(wǎng)絡(luò)應(yīng)用程序的開發(fā)來說是不可能的。因為我們已經(jīng)把控制器分為3個部分,mvc三層(模型/視圖/控制器)的聯(lián)系變得更加寬松。所以它可以明顯提高整個系統(tǒng)的可擴(kuò)充性。在下一節(jié),我們將向你展示一個簡單的例子去解釋如何在三層mvc模式的過程通過增加中間執(zhí)行步驟擴(kuò)大系統(tǒng)框架。4.相關(guān)問題 檢查目前的網(wǎng)絡(luò)應(yīng)用程序設(shè)計模式(如cgi,jsp model2等等),我們可以獲得初步結(jié)果:mvc模式是一個優(yōu)于其他系統(tǒng)邏輯框架的網(wǎng)站應(yīng)用系統(tǒng)開發(fā)模式,它平衡了合作開發(fā)、系統(tǒng)的可擴(kuò)展性和可維護(hù)性。這主要由于舊設(shè)計模式對系統(tǒng)邏輯框架的獨(dú)立性的不足之處。例如,在通過cgi開發(fā)的網(wǎng)頁系統(tǒng)中,cgi程序不僅需

12、要處理執(zhí)行邏輯,同時也負(fù)責(zé)系統(tǒng)報告的格式。因此,它要求開發(fā)者有很強(qiáng)的編程能力(他們必須非常熟悉執(zhí)行規(guī)劃和界面設(shè)計)。此外,它甚至?xí)瓜到y(tǒng)的邏輯層次混亂。最后,混沌編碼會帶來一系列的問題。使用服務(wù)器腳本語言(如asp,php等等)實(shí)現(xiàn)的網(wǎng)頁應(yīng)用系統(tǒng)也不符合要求。其原因是,這些腳本語言都有天生的缺陷(例如,他們卻沒有有好的對象支持和事件響應(yīng)機(jī)制等);他們不能令人滿意地縮短網(wǎng)絡(luò)應(yīng)用系統(tǒng)的執(zhí)行邏輯。由此jsp model2的不足已在上文描述過了,所以沒有這個必要在這贅述了。5.結(jié)論 從上述對系統(tǒng)框圖的分析,我們可以做一個結(jié)論。改進(jìn)后的mvc設(shè)計模式框架比傳統(tǒng)方法有更清楚的結(jié)構(gòu),每個模塊間的聯(lián)系甚少。框

13、架解決是一個大問題,曾困惑很多網(wǎng)絡(luò)開發(fā)者。它將執(zhí)行邏輯從表現(xiàn)模式獨(dú)立出來,實(shí)施并行進(jìn)行發(fā)展。此外,利用模型數(shù)據(jù)庫和lpm數(shù)據(jù)庫,這個更系統(tǒng)的靈活性、可維護(hù)性和可擴(kuò)充性得到了顯著提高。本篇討論的框架已經(jīng)在uest網(wǎng)絡(luò)應(yīng)用系統(tǒng)上得以實(shí)施()。參考文獻(xiàn)1 erich gamma. design patterns. u.s. addison-wesley pub co.2 didier martin. professional xml. u.k. wrox press.3 stephen t. mohr. designing distributed applications with xml, asp

14、, ie5,ldap & msmq. u.k. wrox press.4 sun microsystems inc. javatm servlet 2.3 and javaserver pagestm 1.2 spec fications.5 sun microsystems inc. javaserver pagestm standard tag library specification原文一:a novel web application framedeveloped by mvcluo guangchun wangyanhua lu xianliang hanhong* luo

15、 guangchun, the ph.d. of uest of china; wang yanhua, the master of the uest of china; lu xianliang, the professor of uest of china, advisor of ph.d.; han hong, the ph.d. of uest of china(information center of uest of china, chengdu, china 610054)abstractthe mvc (model/view/controller) design pattern

16、 was developed in smalltalk-80 and widely used in software design. this paper introduces a novel web application frame based on mvc. this frame separates the transaction logic from the presentation format. it also improves the system maintainability, scalability and performance by using the module d

17、atabase, template database, messaging object and buffer queue.key words: mvc, design pattern, web application1. introduction web application system is a transaction system based on b (rowser)/s(erver) model. it exploits many kinds of dynamic web developing technologies. at present, web application d

18、eveloping patterns and tools are one of the topics of the software design. they directly influence several key factors such as maintainability, scalability, stability and the security. in this paper, the purpose of mvc1-based web application design pattern is to resolve the two factors maintainabili

19、ty and scalability, which are the stubborn problems in the web application development. by introducing the mvc design pattern into the web application development, the implementation of system transaction logic can be separated from the system presentation.mvc consists of three kinds of objects. 1)

20、the model: is the application object, 2) the view: is its screen presentation, 3) the controller: defines the way the user interface reacts to user input. before mvc, user interface designs tended to lump these objects together. however, mvc decouples them to increase the flexibility and reuse. mvc

21、decouples views and models by establishing a “subscribe/notify” protocol between them. a view must ensure that its appearance reflects the state of the model correctly. whenever the models data changes, the model notifies views that depend on it. in response, each view gets an opportunity to update

22、itself. this approach lets you attach multiple views to a model to provide different presentations. you can also create new views for a model without rewriting it.2. background and problems even though the mvc design pattern was already put forward in smalltalk-80 and widely used in software design,

23、 it is difficult to introduce it into the web application development. it was mainly due to the following two factors: 1) first, it was difficult to separate the programming language from html. early cgi programs created the html content by using character string output. in nature, it divided the ht

24、ml content into several portions, and then inserted them into the cgi programs. after the appearance of script languages, the way changed to insert the programs written by script languages into html content. however, these two ways had a common deficiency that they could not separate the programs fr

25、om the html content absolutely. therefore, it is very difficult to implement the mvc detached three-layer pattern based on these two ways. 2) second, functions of the script languages are less weak. they lack some necessary technologies to support the mvc design pattern, such as message mechanism an

26、d event response mechanism. this situation did not get any improvement until the release of the jsp model 24. depending on the powerful functions of java language, the jsp model 2 implements the mvc design idea to some extent. figure 1 shows the mechanism: model (the data layer): it is encapsulated

27、into the enterprise javabean. view (the presentation layer): jsp is responsible for the presentation of pages, such as the presentation format, paging, etc. controller (the control layer): servlet receives the user input in pages and executes the relevant transaction (calling the corresponding ejb m

28、odules), then gives the results to the relevant view, so jsp can present these results. this mechanism of jsp model 2 basically meets the developers requirements to detach the web application transaction logic from the user interface. but some limits still exist. for example, although jsp model 2 ha

29、s implemented the basic idea of the mvc design pattern, the relationship of these three layers (servlet, javabean/ejb and jsp) is still close. especially the servlet, which acts as the controller, not only controls the selection and call of models modules, but also is responsible for transferring da

30、ta provided by modules to the corresponding jsp to handle. because of this process, servlet has to implement very complicated transaction logic by itself, which is a tough problem for the system development and maintenance. thus, in the following web application system frame, we will further divide

31、the functions of the controller.3. solution as show in figure 2, this system frame contains three kernel control objects/classes (syscontroller, model center, and lpm (logical page module) center) and their own kernel database (system description database, model database, and lpm database). these th

32、ree control objects/classes are divided from the raw controller. using these control objects/classes and databases, the following parts of this paper will explain the design idea and implementation mechanism of this system frame. firstly, we consider the syscontroller and the system description data

33、base. they are responsible for receiving the user requests and searching the relevant transaction logic according to these requests. the system description database can be a xml2 file or a set of xml files. this database describes the different transaction logic related to different user requests on

34、e by one. the transaction logics mainly include the interactive mode, data sources, and error handling, etc. they are organized in a tree structure. the syscontroller searches the system description database. it combines the user requests and the transaction logic searched out from the database, and

35、 then delivers them to messenger to encapsulate. there are two ways for syscontroller to search the database. one uses the dom (document object model) object3. when the application system boots, this way requires the whole database to be loaded into ram after analyzed by the dom parser. the database

36、 resides in the ram in a dom tree structure. the other one uses sax (simple api for xml) interface. both of them have their own advantages and disadvantages. using dom can implement structural search. it can achieve the efficiency in the case of larger database, but it also costs more system resourc

37、es. the sax interface is famous for its high efficiency and less system resources requirements. the only disadvantage is that it obtains some information less conveniently than the dom does. secondly, we consider the model center and model database.this layer completes the defined transaction logic

38、by calling the given module. model database contains a mass of objects and modules. these objects and modules encapsulate the responding methods relative to specific transaction logic. when model center receives the transaction messages from messenger, it selects suitable objects or modules accordin

39、g to the different transaction logic encapsulated in the message. then it encapsulated the handled data in given format and delivers them to the lpm center. furthermore, each object or module only needs to concern how to implement the given transaction logic and how to obtain the necessary data with

40、out concerning the presentation of these data. lastly, we concern the lpm center and lpm database. lpm is a set of programs to implement the presentation for a certain data type. it can correspond to a disk file or a set of disk files. on the other hand, a certain web page can contain one logical pa

41、ge or multiple logical pages. to a lpm, its function is very simple: it only need to present the given data type without being notified any transaction logic and without concerning the source and content of the data. thus, in the practical development, the lpm is developed by such technologies as la

42、bel library (jsp) or data binding (.net). furthermore, this type of server scripts can be easily understood by the client developers during the ui (user interface) design period and can be developed by some what-you-see-is-what-you-get (wysiwyg) tools. in this portion, lpm center receives the data f

43、rom the model center. it selects the suitable logical page module according to the given data type and transaction logic, then it encapsulates the output of logical page module into http response and sends the response to the client. note that among these three control objects, except syscontroller,

44、the other two do not directly access the their own kernel databases. for example, model center does not directly call the objects or modules in the model database. it implements the access through the modelfactory class instead. (showed in figure 2) according to the analysis of this system frame, we

45、 can see that the whole system perfectly conforms to the mvc design pattern. during the system development period, there is no distinct interactive relationship among the developers in each part. as long as the system frame is established, the development of each part can be preceded in parallel. it

46、 is impossible for the web application developers to use this approach in the past. because we have divided the controller into three parts, the couplings of mvc three layers (model/view/controller) become looser than ever. so it can improve the scalability of the whole system significantly. in the

47、following section, we will show you a simple example to explain how to expand the system frame by adding intermediate transaction processes among the three-layer mvc pattern.4. relative problems examining the present web application design patterns (such as cgi, jsp model 2, etc.), we can gain an el

48、ementary result: web application system developed by mvc pattern excels the one developed by other patterns at the system logical frame, parallel cooperating development, system scalability and maintainability. it is mainly due to the deficiencies of the old design patterns on system logical frame p

49、artition. for example, in web systems developed by cgi, the cgi programs not only need to process the transaction logic, but also are responsible for the system presentation format. therefore, it requires the developers to have very powerful programming ability (they have to be very familiar both with the transaction programming and the interface designing). in addition, it even makes the system logic and hierarchy chaotic. at

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論