计算机 外文翻译 外文文献 英文文献及译文一种新的网络应用程序开发框架——MVC_第1页
计算机 外文翻译 外文文献 英文文献及译文一种新的网络应用程序开发框架——MVC_第2页
计算机 外文翻译 外文文献 英文文献及译文一种新的网络应用程序开发框架——MVC_第3页
计算机 外文翻译 外文文献 英文文献及译文一种新的网络应用程序开发框架——MVC_第4页
计算机 外文翻译 外文文献 英文文献及译文一种新的网络应用程序开发框架——MVC_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、译文一:一种新的网络应用程序开发框架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)的设计模式出现在在smalltalk-80,并在软件的设计中广泛应用。本文介绍一种基于mvc框架的的新网络应用程序。这

2、种框架把实施逻辑与表现形式独立开来。它也提高了系统的可维护性,可扩展性以及使用模块数据库备案、模板数据库,通讯对象和缓冲队列的性能。关键词:mvc、设计模式、网络应用程序1.简介 网络应用系统是一个基于b(rowser)/ s(erver)模型应用系统。它利用多种动态网页开发技术。目前,软件设计的主题之一是网络应用开发模式和工具的。它们直接影响系统的几个关键因素,比如可维护性、可扩展性、稳定性和安全性。本文中,基于mvc1的网络应用程序的设计模式是为解决这两类因素扩展性和可维护性这些不易处理的问题。把mvc设计模式引入网络应用程序开发,执行逻辑可以独立于系统的表现形式。 mvc由三种对象组成。

3、1)模型:是应用对象,2)视图:是它的屏幕的显示,3)控制器:定义用户界面并对输入的信息做出响应。在出现mvc之前,用户界面的设计倾向于把这些东西做在一起。然而,mvc独立了它们,增加系统的灵活性和可重用性。mvc把视图和模型独立开来,在它们之间建立了“subscribe/notify”协议。一个视图必须确保其正确反映模型的状态。每当模型的数据发生改变,视图会得到相应的通知。作为回应,每个视图都会有更新自身的机会。这个方法可以让你附上一个模型的多个视图以便提供不同的报告。你也可以不改变原模型同时创建新的视图。2.背景和存在的问题 虽然mvc的设计模式已经在smalltalk-80中提出了,并广

4、泛应用于软件设计,介绍它到网页应用程序开发却仍很困难的。主要由于以下两个因素:1)首先,很难独立 来自html的编程语言。早期的cgi程序使用字符串输出创造了html内容。默认的,将html文本分成几份,然后把他们嵌入到cgi程序中。脚本语言出现后,变成了脚本语言编写的程序嵌入到html文本中。然而,这两种方法有一个共同的不足,使他们不能完全独立于html文本。因此,这两种方法使采用mvc分离三层模式十分难以实现。2)第二,脚本语言的功能太弱。他们缺乏一些必要的技术支持来采用mvc的设计模式,如消息机制和事件回应机制。直到jsp model2版,这种情况并没有受到任何改善。依靠强大的java语

5、言功能,jsp model24某种程度上实行mvc设计理念。图 1显示了mvc的机制:模型(数据层):它是封装到企业javabean。视图(表示层):jsp负责的网页方式,如报告的格式,分页等。控制器(控制层):servlet受到网页上的用户的输入并执行有关的操作(呼叫相应的ejb组件),给出了相关视图,所以jsp会呈现这些结果。 jsp model2机制主要满足了开发商对要求web应用逻辑和用户界面独立的需求。但制仍然存在某些限,例如,尽管jsp model2已经实施采用mvc设计模式的基本理念,三个层次之间的相互关系(servlet,java bean/ ejb和jsp)仍然封闭。特别是,

6、就servlet当控制器,不仅控制选择同时响应模型的模块,还负责对处理jsp转移数据提供模块。因为这一过程,servlet本身已实现非常复杂的执行逻辑,对于体系的发展和维护这是正是一个棘手的问题。因此,在下面的网络应用系统框架,我们会进一步划分出功能的控制器。3.解决方案 图2中显示,这一系统框架包含三个内核控制对象/类(syscontroller, model center, and lpm(logical page module) center)和它们的核心数据库(system description database, model database, and lpm database)。

7、这三个控制对象/类根据原始的控制器划分。通过这些控制对象/类和数据库,下文将解释部分的设计思想和该系统框架的实现机制。 首先,我们考虑syscontroller和系统的描述数据库。他们负责接收用户的要求和根据这些请求搜索有关的执行逻辑。系统描述数据库可以是一个xml2文件或一套xml文件。这个数据库描述了不同的执行逻辑与不同的用户请求。执行逻辑主要包括互动模式、数据来源与异常处理等,这些组织在一个树形结构中。而syscontroller可以搜索系统描述数据库。它结合了用户的要求和来自数据的执行逻辑,然后把它们交给传输器来封装。syscontroller有两种方法搜索数据库。 其一是使用dom对

8、象(document object model)3。当应用程序系统开机,这样需要dom解析器分析整个数据库备案后载入内存。数据库将保留在内存中的dom树结构。另一种是使用sax(simple api for xml)接口。两者有各自的优缺点。使用dom可以实现结构搜索。它可以在大型数据库上使用,但是会暂用更多的系统资源。而sax接口以高效率和更少的系统资源占用率著称。唯一的缺点是它获得信息比dom难。 其次,我们考虑模型中心和模型数据库。该层通过调用给定模块完成定义执行逻辑。模型数据库包括大量的对象和模块。这些对象和模块根据特定的执行逻辑封装响应方法。当模式中心接收到的执行消息,它根据封装在信

9、息里的执行逻辑选择合适的对象或模块。然后按照给定的数据格式封装模块,冰传输给lpm中心。此外,每个对象或模块只需要关心如何实现给定的事务的逻辑以及如何获得必要的数据而不提交这些数据。 最后,我们研究一下lpm中心和lpm数据库。lpm是实施描述的某一种数据类型的项目集合,它可以当成是一个或一组磁盘文件。在另一方面,有一个网页可有一个逻辑页或多条逻辑页。一个lpm的功能是很简单的:它只需要在没有被得到执行逻辑和原数据内容的情况下给定数据类型。因此事实上,lpm是作为标签库(jsp)或数据捆绑(.net)而开发的。此外,这种类型的服务器脚本可以很容易由客户开发人员在ui(user interfac

10、e)设计阶段理解,what-you-see-is-what-you-get(所见即所得)工具也很容易开发。在这部分,lpm中心从模型中心收到数据。它根据给定数据类型和执行逻辑选择适当的逻辑页模块,然后封装逻辑页的输出模块到http响应并将发布到客户端。注意到这3个控制对象,除了syscontroller,另外两个不是直接进入自己的核心数据库。例如,模式中心不直接从模型数据库调用对象或模块。它实现了通过modelfactory的存取。(过程见图2) 通过分析系统框架,可以看出整个系统完全符合mvc设计模式。在在系统的开发时期各部分的开发者三者冰不具有相互的干涉。当系统框架已确定,各部分惊人的发现

11、开发的相似。在过去这对网络应用程序的开发来说是不可能的。因为我们已经把控制器分为3个部分,mvc三层(模型/视图/控制器)的联系变得更加宽松。所以它可以明显提高整个系统的可扩充性。在下一节,我们将向你展示一个简单的例子去解释如何在三层mvc模式的过程通过增加中间执行步骤扩大系统框架。4.相关问题 检查目前的网络应用程序设计模式(如cgi,jsp model2等等),我们可以获得初步结果:mvc模式是一个优于其他系统逻辑框架的网站应用系统开发模式,它平衡了合作开发、系统的可扩展性和可维护性。这主要由于旧设计模式对系统逻辑框架的独立性的不足之处。例如,在通过cgi开发的网页系统中,cgi程序不仅需

12、要处理执行逻辑,同时也负责系统报告的格式。因此,它要求开发者有很强的编程能力(他们必须非常熟悉执行规划和界面设计)。此外,它甚至会使系统的逻辑层次混乱。最后,混沌编码会带来一系列的问题。使用服务器脚本语言(如asp,php等等)实现的网页应用系统也不符合要求。其原因是,这些脚本语言都有天生的缺陷(例如,他们却没有有好的对象支持和事件响应机制等);他们不能令人满意地缩短网络应用系统的执行逻辑。由此jsp model2的不足已在上文描述过了,所以没有这个必要在这赘述了。5.结论 从上述对系统框图的分析,我们可以做一个结论。改进后的mvc设计模式框架比传统方法有更清楚的结构,每个模块间的联系甚少。框

13、架解决是一个大问题,曾困惑很多网络开发者。它将执行逻辑从表现模式独立出来,实施并行进行发展。此外,利用模型数据库和lpm数据库,这个更系统的灵活性、可维护性和可扩充性得到了显著提高。本篇讨论的框架已经在uest网络应用系统上得以实施()。参考文献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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论