版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
外文资料翻译译文一种新的网络应用程序开发框架——MVC摘要:MVC(Model/View/Controller)的设计模式出现在在Smalltalk-80,并在软件的设计中广泛应用。本文介绍一种基于MVC框架的的新网络应用程序。这种框架把实施逻辑与表现形式独立开来。它也提高了系统的可维护性,可扩展性以及使用模块数据库备案、模板数据库,通讯对象和缓冲队列的性能。关键词:MVC、设计模式、网络应用程序1.简介网络应用系统是一个基于B(rowser)/S(erver)模型应用系统。它利用多种动态网页开发技术。目前,软件设计的主题之一是网络应用开发模式和工具的。它们直接影响系统的几个关键因素,比如可维护性、可扩展性、稳定性和安全性。本文中,基于MVC[1]的网络应用程序的设计模式是为解决这两类因素——扩展性和可维护性这些不易处理的问题。把MVC设计模式引入网络应用程序开发,执行逻辑可以独立于系统的表现形式。MVC由三种对象组成。1)模型:是应用对象,2)视图:是它的屏幕的显示,3)控制器:定义用户界面并对输入的信息做出响应。在出现MVC之前,用户界面的设计倾向于把这些东西做在一起。然而,MVC独立了它们,增加系统的灵活性和可重用性。MVC把视图和模型独立开来,在它们之间建立了“subscribe/notify”协议。一个视图必须确保其正确反映模型的状态。每当模型的数据发生改变,视图会得到相应的通知。作为回应,每个视图都会有更新自身的机会。这个方法可以让你附上一个模型的多个视图以便提供不同的报告。你也可以不改变原模型同时创建新的视图。2.背景和存在的问题虽然MVC的设计模式已经在smalltalk-80中提出了,并广泛应用于软件设计,介绍它到网页应用程序开发却仍很困难的。主要由于以下两个因素:1)首先,很难独立来自OC的编程语言。早期的CGI程序使用字符串输出创造了HTML内容。默认的,将HTML文本分成几份,然后把他们嵌入到CGI程序中。脚本语言出现后,变成了脚本语言编写的程序嵌入到HTML文本中。然而,这两种方法有一个共同的不足,使他们不能完全独立于HTML文本。因此,这两种方法使采用MVC分离三层模式十分难以实现。2)第二,脚本语言的功能太弱。他们缺乏一些必要的技术支持来采用MVC的设计模式,如消息机制和事件回应机制。直到Model2版,这种情况并没有受到任何改善。依靠强大的OC语言功能,Model2[4]某种程度上实行MVC设计理念。图1显示了MVC的机制:•模型(数据层):它是封装到企业JavaBean。•视图(表示层):view负责的网页方式,如报告的格式,分页等。•控制器(控制层):Servlet受到网页上的用户的输入并执行有关的操作(呼叫相应的EJB组件),给出了相关视图,所以会呈现这些结果。Model2机制主要满足了开发商对要求Web应用逻辑和用户界面独立的需求。但制仍然存在某些限,例如,尽管Model2已经实施采用MVC设计模式的基本理念,三个层次之间的相互关系(Servlet,JavaBean/EJB)仍然封闭。特别是,就Servlet当控制器,不仅控制选择同时响应模型的模块,还负责对处理JSP转移数据提供模块。因为这一过程,Servlet本身已实现非常复杂的执行逻辑,对于体系的发展和维护这是正是一个棘手的问题。因此,在下面的网络应用系统框架,我们会进一步划分出功能的控制器。3.解决方案图2中显示,这一系统框架包含三个内核控制对象/类(UIViewController,ModelCenter,andLPM(LogicalPageModule)Center)和它们的核心数据库(systemdescriptiondatabase,modeldatabase,andLPMdatabase)。这三个控制对象/类根据原始的控制器划分。通过这些控制对象/类和数据库,下文将解释部分的设计思想和该系统框架的实现机制。首先,我们考虑UIViewController和系统的描述数据库。他们负责接收用户的要求和根据这些请求搜索有关的执行逻辑。系统描述数据库可以是一个XML[2]文件或一套XML文件。这个数据库描述了不同的执行逻辑与不同的用户请求。执行逻辑主要包括互动模式、数据来源与异常处理等,这些组织在一个树形结构中。而UIViewController可以搜索系统描述数据库。它结合了用户的要求和来自数据的执行逻辑,然后把它们交给传输器来封装。UIViewController有两种方法搜索数据库。其一是使用DOM对象(DocumentObjectModel)[3]。当应用程序系统开机,这样需要DOM解析器分析整个数据库备案后载入内存。数据库将保留在内存中的DOM树结构。另一种是使用SAX(SimpleAPIforXML)接口。两者有各自的优缺点。使用DOM可以实现结构搜索。它可以在大型数据库上使用,但是会暂用更多的系统资源。而SAX接口以高效率和更少的系统资源占用率著称。唯一的缺点是它获得信息比DOM难。其次,我们考虑模型中心和模型数据库。该层通过调用给定模块完成定义执行逻辑。模型数据库包括大量的对象和模块。这些对象和模块根据特定的执行逻辑封装响应方法。当模式中心接收到的执行消息,它根据封装在信息里的执行逻辑选择合适的对象或模块。然后按照给定的数据格式封装模块,冰传输给LPM中心。此外,每个对象或模块只需要关心如何实现给定的事务的逻辑以及如何获得必要的数据而不提交这些数据。最后,我们研究一下LPM中心和LPM数据库。LPM是实施描述的某一种数据类型的项目集合,它可以当成是一个或一组磁盘文件。在另一方面,有一个网页可有一个逻辑页或多条逻辑页。一个LPM的功能是很简单的:它只需要在没有被得到执行逻辑和原数据内容的情况下给定数据类型。因此事实上,LPM是作为标签库(JSP)或数据捆绑(.net)而开发的。此外,这种类型的服务器脚本可以很容易由客户开发人员在UI(userinterface)设计阶段理解,what-you-see-is-what-you-get(所见即所得)工具也很容易开发。在这部分,LPM中心从模型中心收到数据。它根据给定数据类型和执行逻辑选择适当的逻辑页模块,然后封装逻辑页的输出模块到HTTP响应并将发布到客户端。注意到这3个控制对象,除了UIViewController,另外两个不是直接进入自己的核心数据库。例如,模式中心不直接从模型数据库调用对象或模块。它实现了通过ModelFactory的存取。(过程见图2)通过分析系统框架,可以看出整个系统完全符合MVC设计模式。在在系统的开发时期各部分的开发者三者冰不具有相互的干涉。当系统框架已确定,各部分惊人的发现开发的相似。在过去这对网络应用程序的开发来说是不可能的。因为我们已经把控制器分为3个部分,MVC三层(模型/视图/控制器)的联系变得更加宽松。所以它可以明显提高整个系统的可扩充性。在下一节,我们将向你展示一个简单的例子去解释如何在三层MVC模式的过程通过增加中间执行步骤扩大系统框架。4.相关问题检查目前的网络应用程序设计模式(如CGI,Model2等等),我们可以获得初步结果:MVC模式是一个优于其他系统逻辑框架的网站应用系统开发模式,它平衡了合作开发、系统的可扩展性和可维护性。这主要由于旧设计模式对系统逻辑框架的独立性的不足之处。例如,在通过CGI开发的网页系统中,CGI程序不仅需要处理执行逻辑,同时也负责系统报告的格式。因此,它要求开发者有很强的编程能力(他们必须非常熟悉执行规划和界面设计)。此外,它甚至会使系统的逻辑层次混乱。最后,混沌编码会带来一系列的问题。使用服务器脚本语言(如ASP,PHP等等)实现的网页应用系统也不符合要求。其原因是,这些脚本语言都有天生的缺陷(例如,他们却没有有好的对象支持和事件响应机制等);他们不能令人满意地缩短网络应用系统的执行逻辑。由此Model2的不足已在上文描述过了,所以没有这个必要在这赘述了。5.结论从上述对系统框图的分析,我们可以做一个结论。改进后的MVC设计模式框架比传统方法有更清楚的结构,每个模块间的联系甚少。框架解决是一个大问题,曾困惑很多网络开发者。它将执行逻辑从表现模式独立出来,实施并行进行发展。此外,利用模型数据库和LPM数据库,这个更系统的灵活性、可维护性和可扩充性得到了显著提高。本篇讨论的框架已经在UEST网络应用系统上得以实施()。外文原文ANovelWebApplicationFrameDevelopedbyMVCLuoGuangChunWangYanhuaLuXianliangHanhong(InformationCenterofUESTofChina,ChengDu,China610054)AbstractTheMVC(Model/View/Controller)designpatternwasdevelopedinSmalltalk-80andwidelyusedinsoftwaredesign.ThispaperintroducesanovelWebapplicationframebasedonMVC.Thisframeseparatesthetransactionlogicfromthepresentationformat.Italsoimprovesthesystemmaintainability,scalabilityandperformancebyusingthemoduledatabase,templatedatabase,messagingobjectandbufferqueue.Keywords:MVC,DesignPattern,WebApplication1.IntroductionWebapplicationsystemisatransactionsystembasedonB(rowser)/S(erver)model.ItexploitsmanykindsofdynamicWebdevelopingtechnologies.Atpresent,Webapplicationdevelopingpatternsandtoolsareoneofthetopicsofthesoftwaredesign.Theydirectlyinfluenceseveralkeyfactorssuchasmaintainability,scalability,stabilityandthesecurity.Inthispaper,thepurposeofMVC[1]-basedWebapplicationdesignpatternistoresolvethetwofactors–maintainabilityandscalability,whicharethestubbornproblemsintheWebapplicationdevelopment.ByintroducingtheMVCdesignpatternintotheWebapplicationdevelopment,theimplementationofsystemtransactionlogiccanbeseparatedfromthesystempresentation.MVCconsistsofthreekindsofobjects.1)theModel:istheapplicationobject,2)theView:isitsscreenpresentation,3)theController:definesthewaytheuserinterfacereactstouserinput.BeforeMVC,userinterfacedesignstendedtolumptheseobjectstogether.However,MVCdecouplesthemtoincreasetheflexibilityandreuse.MVCdecouplesviewsandmodelsbyestablishinga“subscribe/notify”protocolbetweenthem.Aviewmustensurethatitsappearancereflectsthestateofthemodelcorrectly.Wheneverthemodel’sdatachanges,themodelnotifiesviewsthatdependonit.Inresponse,eachviewgetsanopportunitytoupdateitself.Thisapproachletsyouattachmultipleviewstoamodeltoprovidedifferentpresentations.Youcanalsocreatenewviewsforamodelwithoutrewritingit.2.BackgroundandProblemsEventhoughtheMVCdesignpatternwasalreadyputforwardinsmalltalk-80andwidelyusedinsoftwaredesign,itisdifficulttointroduceitintotheWebapplicationdevelopment.Itwasmainlyduetothefollowingtwofactors:1)First,itwasdifficulttoseparatetheprogramminglanguagefromHTML.EarlyCGIprogramscreatedtheHTMLcontentbyusingcharacterstringoutput.Innature,itdividedtheHTMLcontentintoseveralportions,andtheninsertedthemintotheCGIprograms.AftertheappearanceofScriptlanguages,thewaychangedtoinserttheprogramswrittenbyscriptlanguagesintoHTMLcontent.However,thesetwowayshadacommondeficiencythattheycouldnotseparatetheprogramsfromtheHTMLcontentabsolutely.Therefore,itisverydifficulttoimplementtheMVCdetachedthree-layerpatternbasedonthesetwoways.2)Second,functionsofthescriptlanguagesarelessweak.TheylacksomenecessarytechnologiestosupporttheMVCdesignpattern,suchasmessagemechanismandeventresponsemechanism.ThissituationdidnotgetanyimprovementuntilthereleaseoftheJSPModel2[4].DependingonthepowerfulfunctionsofOClanguage,theJSPModel2implementstheMVCdesignideatosomeextent.Figure1showsthemechanism:•Model(thedatalayer):itisencapsulatedintotheEnterpriseJavaBean.•View(thepresentationlayer):JSPisresponsibleforthepresentationofpages,suchasthepresentationformat,paging,etc.•Controller(thecontrollayer):Servletreceivestheuserinputinpagesandexecutestherelevanttransaction(callingthecorrespondingEJBmodules),thengivestheresultstotherelevantView,soJSPcanpresenttheseresults.ThismechanismofJSPModel2basicallymeetsthedevelopers’requirementstodetachtheWebapplicationtransactionlogicfromtheuserinterface.Butsomelimitsstillexist.Forexample,althoughJSPModel2hasimplementedthebasicideaoftheMVCdesignpattern,therelationshipofthesethreelayers(Servlet,JavaBean/EJBandJSP)isstillclose.EspeciallytheServlet,whichactsastheController,notonlycontrolstheselectionandcallofModel’smodules,butalsoisresponsiblefortransferringdataprovidedbymodulestothecorrespondingJSPtohandle.Becauseofthisprocess,Servlethastoimplementverycomplicatedtransactionlogicbyitself,whichisatoughproblemforthesystemdevelopmentandmaintenance.Thus,inthefollowingWebapplicationsystemframe,wewillfurtherdividethefunctionsoftheController.3.SolutionAsshowinFigure2,thissystemframecontainsthreekernelcontrolobjects/classes(UIViewController,ModelCenter,andLPM(LogicalPageModule)Center)andtheirownkerneldatabase(systemdescriptiondatabase,modeldatabase,andLPMdatabase).Thesethreecontrolobjects/classesaredividedfromtherawController.Usingthesecontrolobjects/classesanddatabases,thefollowingpartsofthispaperwillexplainthedesignideaandimplementationmechanismofthissystemframe.Firstly,weconsidertheUIViewControllerandtheSystemDescriptionDatabase.Theyareresponsibleforreceivingtheuserrequestsandsearchingtherelevanttransactionlogicaccordingtotheserequests.TheSystemDescriptionDatabasecanbeaXML[2]fileorasetofXMLfiles.Thisdatabasedescribesthedifferenttransactionlogicrelatedtodifferentuserrequestsonebyone.Thetransactionlogicsmainlyincludetheinteractivemode,datasources,anderrorhandling,etc.Theyareorganizedinatreestructure.TheUIViewControllersearchestheSystemDescriptionDatabase.Itcombinestheuserrequestsandthetransactionlogicsearchedoutfromthedatabase,andthendeliversthemtoMessengertoencapsulate.TherearetwowaysforUIViewControllertosearchthedatabase.OneusestheDOM(DocumentObjectModel)object[3].Whentheapplicationsystemboots,thiswayrequiresthewholedatabasetobeloadedintoRAMafteranalyzedbytheDOMParser.ThedatabaseresidesintheRAMinaDOMtreestructure.TheotheroneusesSAX(SimpleAPIforXML)interface.Bothofthemhavetheirownadvantagesanddisadvantages.UsingDOMcanimplementstructuralsearch.Itcanachievetheefficiencyinthecaseoflargerdatabase,butitalsocostsmoresystemresources.TheSAXinterfaceisfamousforitshighefficiencyandlesssystemresourcesrequirements.TheonlydisadvantageisthatitobtainssomeinformationlessconvenientlythantheDOMdoes.Secondly,weconsidertheModelCenterandModelDatabase.Thislayercompletesthedefinedtransactionlogicbycallingthegivenmodule.ModelDatabasecontainsamassofobjectsandmodules.Theseobjectsandmodulesencapsulatetherespondingmethodsrelativetospecifictransactionlogic.WhenModelCenterreceivesthetransactionmessagesfromMessenger,itselectssuitableobjectsormodulesaccordingtothedifferenttransactionlogicencapsulatedinthemessage.ThenitencapsulatedthehandleddataingivenformatanddeliversthemtotheLPMCenter.Furthermore,eachobjectormoduleonlyneedstoconcernhowtoimplementthegiventransactionlogicandhowtoobtainthenecessarydatawithoutconcerningthepresentationofthesedata.Lastly,weconcerntheLPMCenterandLPMDatabase.LPMisasetofprogramstoimplementthepresentationforacertaindatatype.Itcancorrespondtoadiskfileorasetofdiskfiles.Ontheotherhand,acertainWebpagecancontainonelogicalpageormultiplelogicalpages.ToaLPM,itsfunctionisverysimple:itonlyneedtopresentthegivendatatypewithoutbeingnotifiedanytransactionlogicandwithoutconcerningthesourceandcontentofthedata.Thus,inthepracticaldevelopment,theLPMisdevelopedbysuchtechnologiesaslabellibrary(JSP)ordatabinding(.Net).Furthermore,thistypeofserverscriptscanbeeasilyunderstoodbytheclientdevelopersduringtheUI(userinterface)designperiodandcanbedevelopedbysomewhat-you-see-is-what-you-get(WYSIWYG)tools.Inthisportion,LPMCenterreceivesthedatafromtheModelCenter.Itselectsthesuitablelogicalpagemoduleaccordingtothegivendatatypeandtransactionlogic,thenitencapsulatestheoutputoflogicalpagemoduleintoHTTPresponseandsendstheresponsetotheclient.Notethatamongthesethreecontrolobjects,exceptUIViewController,theothertwodonotdirectlyaccessthetheirownkerneldatabases.Forexample,ModelCenterdoesnotdirectlycalltheobjectsormodulesintheModelDatabase.ItimplementstheaccessthroughtheModelFactoryclassinstead.(Showedinfigure2)Accordingtotheanalysisofthissystemframe,wecanseethatthewholesystemperfectlyconformstotheMVCdesignpattern.Duringthesystemdevelopmentperiod,thereisnodistinctinteractiverelationshipamongthedevelopersineachpart.Aslongasthesystemframeisestablished,thedevelopmentofeachpartcanbeprecededinparallel.ItisimpossiblefortheWebapplicationdeveloperstousethisapproachinthepast.BecausewehavedividedtheControllerintothreeparts,thecouplingsofMVCthreelayers(Model/View/Controller)becomelooserthanever.Soitcanimprovethescalabilityofthewholesystemsignificantly.Inthefollowingsection,wewillshowyouasimpleexampletoexplainhowtoexpandthesystemframebyaddingintermediatetransactionprocessesamongthethree-layerMVCpattern.4.RelativeproblemsExaminingthepresentWebapplicationdesignpatterns(suchasCGI,JSPMODEL2,etc.),wecangainanelementaryresult:WebapplicationsystemdevelopedbyMVCpatternexcelstheonedevelopedbyotherpatternsatthesystemlogicalframe,parallelcooperatingdevelopment,systemscalabilityandmaintainability.Itismainlyduetothedeficienciesoftheolddesignpatternsonsystemlogicalframepartition.Forexample,inWebsystemsdevelopedbyCGI,theCGIprogramsnotonlyneedtoprocessthetransactionlogic,butalsoareresponsibleforthesystempresentationformat.Therefore,itrequiresthedeveloperstohaveverypowerfulprogrammingability(theyhavetobeveryfamiliarbothwiththetransactionprogrammingandtheinterfacedesigning).Inaddition,itevenmakesthesystemlogicandhierarchychaotic.Atlastthechaoticcodeswillleadintoaseriesofproblems.Usingtheserverscriptlanguages(suchasASP,PHP,etc.)toimplementWebapplicationsystemsisalsonotsatisfactory.Thereasonisthatthescriptlanguageshaveinnatedeficiencies(forexample,theydonothavegoodobjectsupportingandeventresponsemechanism);theycannotsatisfactorilyencapsulatethetransactionlogicsofWebapplicationsystems.ThedeficienciesofJSPModel2havebeendescribedintheabovepartofthispaper,soithasnoneedtobepresentedinhereagain.5.ConclusionFromtheanalysisofthesystemframeabove,wecandrawaconclusion.TheimprovedWebapplicationsystemframebasedonMVCdesignpatternhasclearerstructurethantraditionalones.Thecouplingsamongeachmodulearelooser.Especially,thisframeresolvesabigproblem,whichpuzzledWebdevelopersforalongtime.Itseparatesthetransactionlogicfrompresentation,andimplementstheparallelproceedingindevelopment.Furthermore,byusingtheModelDatabaseandLPMDatabase,theflexibility,maintainabilityandscalabilityofthewholesystemhavebeenimprovedgreatly.TheframediscussedinthispaperhasbeenappliedinthewebapplicationsystemofUESTofChina().目录TOC\o"1-2"\h\z\u1总论 11.1项目摘要 11.2编制依据与研究范围 31.3建设规模 41.4主要建设内容 41.5投资估算及资金筹措 41.6工程效益 52投资环境及建设条件分析 62.1投资环境分析 62.2建设条件分析 103项目建设的必要性与可行性分析 153.1项目建设的必要性 153.2项目建设的可行性 164开发区规划与交通量预测 174.1项目区总体规划 174.2项目影响范围的交通量预测 185工程建设方案 215.1设计标准及设计规范 215.2道路设计方案 225.3给排水工程设计 285.4道路照明 345.5电力综合管沟 355.6道路绿化工程 355.7交通安全及管理设施 356节能分析 376.1设计依据 376.2项目概况 376.3项目对所在地能源供应状况的影响 376.4项目用能方案、用能设备 386.5项目能源消耗量、能源消费结构、效率水平和能源管理水平 386.6节能措施分析评价 386.7节能措施建议 396.8结论 397环境保护 40HYPERLINK\l"_Toc335141
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 深度解析(2026)《jbt+12944-2016热镀锌机组用活套》
- 2025-2026学年第三章一次函数复习课湘教版八年级数学下学期(课件)
- 0-3岁婴幼儿卫生与保健
- 精神科焦虑症护理管理规范
- 神经外科脑出血护理措施介绍
- 川剧文化创意设计体系构建
- 肝内科肝硬化并发症防治措施
- 儿童脑膜炎早期诊断与处理流程
- 高端品牌VI设计系统构建
- 粉刷匠教学设计
- 2025年高考语文全国一卷试题真题及答案详解(精校打印)
- 设备安装、调试、验收管理制度
- 江苏省常州市钟楼区2024-2025学年六年级下学期小升初招生数学试卷含解析
- 五年级下册语文1-8单元习作范文寒假积累素材
- 八年级培训机构家长会
- 防灭火细则培训课件
- 2025年能源控股集团所属辽宁铁法能源有限责任公司招聘笔试参考题库附带答案详解
- 临床护理带教现状及改善
- 战略管理知到智慧树章节测试课后答案2024年秋华南理工大学
- 2025年高考英语完形填空+语法填空专练(原卷版+解析版)
- 《变电站电气主接线》课件
评论
0/150
提交评论