课程自主学习实施系统-英文文献翻译外文翻译资料

 2022-08-26 04:08

Curriculum independent learning implementation system

An overview of the MVC Model Studies

Abstract: as the object oriented technique develops, the use of MVC became w ider and wider, and no longer limited to the construction of component, it can also be used in the softw are design of large object oriented system, such as the electronic com merce. this paper starts w ith the origin of the MVC pattern, discusses about the structure, design im implementation tech niques, good side and bad side, and the application of it. At the end of this paper, MVC2 structure is discussed, which is construct of JSP, servlet and javabeans.

Key words: model view controller( MVC);Mvc2;

The early graphical program design often revolve around an event-driven user interface to the organization, such as a direct consequence of data processing, the features and the code, some completely tangles[1] . The large graphical program is a data usually corresponds to the number of means and waysof dealing with the specific interface bound to the application of a serious reduction in the flexibility of the program, making it a very small changes are also involved a large amount of code, application development and maintenance efforts.

In the 1970 s, the MVC (model view controller) Mode in the small-talk-80 GUI design is raised.The MVC model to data processing, the Program Input Output Control, as well as the separation of dataand describes the different parts of the communication between objectsso that they do not need to become involved in each others data model and waysto make the program structure becomes clear and flexible. The JSP, servlets and java beansfor the J2EE based MVCstructure has allowed the MVC model widely used in large-scale web project development. This article focuses on the structure of the MVC patterns, design, and implementation of key technologies.

1.1 The structure of the MVC Mode

The MVC pattern consists of three parts: Model(model) , the view(view) and the Controller(controller, correspond to the internal data, data representation and Input Output Control section. A more reasonable abbreviation should be MDMAVC[ , MD, which means the domain model, an analyst and designers part, is a description of the problem; Ma refers to the application model is used to record the viewsand access to the view information and send a message to the view.

1.1 model

The model is relevant to the issue of the logical data abstraction, on behalf of the intrinsic properties of the object that is at the core of the model. It is an object-oriented approach to problem areas in the abstraction of application objects, these abstract objects encapsulate the object belongs.And the object of logic. The role of the model are as follows: The abstract application featuresthat encapsulate the structure and operationof the con troller provides access to functionality of the program; and ! To view the data query request;when the data changes, notification of interest to this data view .

1.2 View

View the outward manifestation of the model, a model can be corresponds to one or more views, such as the graphical user interface, the command-line view,APIview; or by user category: New Users View, skilled users view, and so on.

The view has the capability to interact with the outside world, is the application of the system from the outside interface:On the one hand, it provides a means for external input, and trigger the application of the logical operation; on the other hand. It would be logical to run results in one way or another, it appears to the outside world. When themodelchanges, it has made the appropriate changes, there are two ways: push( push) method, to view themodelfor registration, the m odel as changes are made to the registered viewsends an update message; pull( ) , V iew in need access to up-to-date data is transferredusing a m odel .The view is as follows: the role of the performance of the data portion of the abstract; the data is displayed to the user, the user input; ! The user will be forwarded to the controller; and (4) When a from the m odel s data has been updated , update the % Notification message displays.

1.3 Controller

The controller is the model and the viewof the link between the controller to extract via the View transfer incoming external informationand user interaction with the view to based on the application of the standard business events, then the standard business events to model should perform the action( including the activation of the business logic and change the model status) . At the same time, theModel Updates and modifications will also be notified by the controller to view, thus preserving the view and the model. The role of the controller are as follows: (1) The abstract user interaction and application semantics mapping; (2) the user input into the applications behavior, and forwarded to the model; (3) based on the user input and model for the output, select the appropriate view to display data.

1.4 MVC of the relationship between the three parts.

As in the general program structure, the MVC has input, processing and output in three parts: the controller corresponds to the inputof the model corresponds to the data representation and dataview,corresponds to the output. Oneof the controller with the platform and operating system most closely connected, view the segment(view does not care about the event from the microsoft windows and X windows), the model is platform-independent.

MVCmode is usually define a restricted connection collection, to describe the model, view and controller, as well as the communication between the data and control information for the delivery and direction.M V C mode for the three parts of the communication in accordance with the provisions of this collection.

2. The advantages and disadvantages of MVC Mode

2.1 The MVC Model

剩余内容已隐藏,支付完成后下载完整资料


课程自主学习实施系统-英文文献翻译

MVC 模式研究的综述

摘 要: 随着面向对象技术的发展, MVC 的含义和用途变得更加广泛, 不仅可以用于组件的构造, 也可用于类似于电子商务应用等大型面向对象系统的软件设计。从MVC 模式起源开始, 讨论了 MVC 模式的结构、设计方法、实现技术、优缺点及其应用, 最后介绍了由 JSP, Servlet 和 JaveBeans 实现的 MVC2 结构。

关键词: MVC; MVC2; 设计模式

早期的图形化程序设计常常围绕着事件驱动的用户界面来组织, 这样的直接后果就是数据处理、程序功能与显示代码等部分完全纠结在一起[ 1] 。大型的图形化程序中一个数据通常对应多种表示与处理方式, 把特定界面绑定到应用程序上严重降低了程序的灵活性, 使得一个很小的改动也牵涉到大量的代码, 增加了程序开发与维护的工作量。

20世纪 70 年代, MVC( Model View Controller) 模式在 Small-talk-80 的 GUI 设计中被提出。MVC 模式把数据处理、程序输入输出控制以及数据表示分离开来, 并且描述了不同部分的对象之间的通信方式, 使它们不必卷入彼此的数据模型和方法中, 使程序结构变得清晰而灵活。由 JSP, Servlet 和 Java Beans实现的基于 J2EE 的 MVC结构的出现使得 MVC 模式广泛地应用于大型的 Web 项目的开发中。本文重点介绍了 MVC 模式的结构、设计方法和实现的关键技术。

1.MVC 模式的结构

MVC 模式包括三个部分: 模型( Model) 、视图( View) 和控制器( Controller) , 分别对应于内部数据、数据表示和输入输出控制部分。一个更为合理的缩写应该是 MdMaVC[ , 其中, Md 指 Domain Model, 是分析员和设计师所面对的部分, 是对问题的描述; Ma指Application Model, 用来记录存在的视图, 获取视图信息和向视图发送消息。

1.1 模型 (Model)

模型是与问题相关数据的逻辑抽象, 代表对象的内在属性, 是整个模型的核心。它采用面向对象的方法, 将问题领域中的对象抽象为应用程序对象, 在这些抽象的对象中封装了对象的属。性和这些对象所隐含的逻辑。模型的作用如下: 抽象应用程序的功能, 封装程序数据的结构及其操作; 向 Con troller 提供对程序功能的访问; ! 接受 View 的数据查询请求;当数据有变化时, 通知对此数据感兴趣的 View 。

1.2 视图( View)

视图是模型的外在表现, 一个模型可以对应一个或者多个视图, 如图形用户界面视图、命令行视图、API视图; 或按使用者分类: 新用户视图、熟练用户视图等。

视图具有与外界交互的功能, 是应用系统与外界的接口:一方面它为外界提供输入手段, 并触发应用逻辑运行; 另一方面。它又将逻辑运行的结果以某种形式显示给外界。当Model变化时, 它作出相应变化, 有两种方法: Push( 推) 方法, 让 View 在Model处注册, M odel 在发生变化时向已注册的 View发送更新消息; Pull( 拉) 方法, V iew 在需要获得最新数据时调用M odel 的方法。View 的作用如下: 对数据的表现部分进行抽象; 将数据展现给用户, 获得用户输入; ! 将用户输入转发给 Controller ; ( 4) 当接到来自 M odel 的 数据已更新% 通知后, 更新显示信息。

1.3 控制器( Controller)

控制器是模型与视图的联系纽带, 控制器提取通过视图传输进来的外部信息, 并将用户与 View 的交互转换为基于应用程序行为的标准业务事件, 再将标准业务事件解析为 Model 应执行的动作( 包括激活业务逻辑和改变 Model 的状态) 。同时,模型的更新与修改也将通过控制器来通知视图, 从而保持各个视图与模型的一致性。Controller 的作用如下: ( 1) 抽象用户交互和应用程序语义的映射; ( 2) 将用户输入翻译成应用程序的动作, 并转发给 Model; ( 3) 根据用户输入和 Model 对程序动作的输出, 选择适当的 View 来展现数据。

4 MVC 三部分之间的关系

如同一般的程序结构一样, MVC 有输入、处理、输出三个部分: Controller 对应于输入, Model 对应于数据表示和数据处理, View对应于输出。其中, 控制器与平台和操作系统的关系最为密切, View 与之部分相关( View 并不在意事件是来自 Microsoft Windows 还是 X Windows) , Model 与平台无关 。

MVC模式通常定义一个受限连接集合, 用以描述模型、视图与控制器之间的通信, 以及数据和控制信息的传递方式与方向。M V C 模式中三个部分之间的通信都按照这个集合的规定进行。

2.MVC 模式的优缺点

2.1 MVC 模式的优点

分离稳定的代码和易变的代码是面向对象设计的一个基本原则。通常负责控制部分的对象要比负责表现部分的对象稳定, 而负责业务逻辑和业务数据的对象比前两类对象更稳定。MVC 设计模式分离了程序的表现、控制和数据, 具有设计清晰、易于扩展、运用可分布的特点, 因此在构建 Web 应用中具有显著的优势, 可适用于多用户的、可扩展的、可维护的、具有很高交互性的系统, 如电子商务平台、CRM 系统和 ERP 系统等。它可以很好地表达用户与系统的交互模式以及整个系统的程序架构模式。MVC 模式有如下优点:

1) 将数据建模、数据显示和用户交互三者分开, 使得程序设计的过程更清晰, 提高了可复用程度;

2) 当接口设计完成以后, 可以开展并行开发, 从而提高了开发效率;

3) 可以很方便地用多个视图来显示多套数据, 从而使系统能方便地支持其他新的客户端类型;

4) 模式中各组件的分界线就是很自然的分发接口点, 使得应用程序的发布更容易, 并且支持渐进式升级;

5) 各部分的责任划分得很清楚, 从而简化了测试工作, 维护人员很容易了解程序的结构, 便于维护工作的进行;

6) 提高了系统灵活性, 因为数据模型、用户交互和数据显示等部分都可以设计为可接插组件;

7) 可以用于分布式开发, 只要给 Model, View 和 Controller 使用代理( Proxy) , 就可以封装不同计算机之间的通信。

2 .2 MVC 模式的缺点

MVC 模式的缺点主要集中在两个方面:

1) 由于实施 MVC 模式过程而产生的开销。设计 MVC 模式需要有经验的分析人员对系统进行分析; 类的数量及文件数量的增加(像C 这样的编程语言, 一个类对应两个文件) 。

2) 由于设计 MVC 模式时分析不够、设计不当而引起相反的效果, 把属于一个模块的分开, 把不相干的模块聚在一起。对属于一个实体不同方面的严格区分导致了一个紧凑结构, 使得测试和维护的工作量大幅度增加, 每一次变动牵涉到许多本不相干的模块的变动。

3 MVC 模式的设计方法

M VC 模式将目标系统分为三个部分: 模型、视图和控制器, 并要定义描述三个部分之间通信的受限连接集合。相应地, MVC 模式的设计包括四个部分: MVC通信的设计、模型的设计、视图的设计和控制器的设计。

3.1 MVC 通信的设计方法

在MVC模式中, 模型、视图和控制器这三个部分之间的通信是通过定义一个受限连接的集合来描述的。可以采用带箭头连线对在各个部分之间进行的信息和控制传递作出形象的表示, 并具体描述每个带箭头连线的含义。在实现上, 模型、视图和控制器这三个部分之间的通信是通过相应的模型对象、视图对象和控制器对象之间的消息通信完成的。原则上应该尽量减少三个部分之间的结合, 增强隔离性, 使模型部分可以不必了解数据表示和与用户交互的细节就可以完成数据处理, 使视图不必了解模型进行数据处理的内部实现就可以完成数据表示的功能。

3. 2 模型的设计方法

模型是进行数据处理的地方, 表达了实际应用中的业务处理逻辑。模型由许多模型对象及这些对象之间的各种各样的关系构成。模型对象是根据问题域中的对象构建的, 带有一些有意义的属性和方法, 它们之间有这样或那样的关系, 如一般特殊关系、整体部分关系、实例关联、消息关联等, 它们相互交互完成数据处理功能。

3. 3 视图的设计方法

视图是表达数据显示逻辑的地方, 通常完成或辅助完成 G U I 功能。视图对象通常用于保存一些从模型对象中得到的信息, 但视图对象并不完全与模型对象相同。模型中有的对象在视图中可能没有, 与模型对象对应的视图对象一般也具有与之不同的属性和方法, 反之亦然。主要有两种方式实现视图对象: (1) 视图对象是模型对象的一个代表, 持有对相应模型对象的一个引用, 相应地, 在视图对象的方法中通过这个引用将调用都传递到模型对象中去。(2) 视图对象不必实现与模型对象相同的接口方法, 它拥有的是一些属性, 反映了满足显示需要的数据, 并可以从模型对象中获取相应的值。在构建视图对象的时候就使用实际模型对象初始化视图对象的状态, 也就是给视图对象的属性赋值, 实现数据传递。

3.4 控制器的设计方法

控制器在用户和视图之间交互, 完成接收用户输入并控制显示流程转换的功能, 它充当了模型与视图之间的去耦层。控制器中的对象用于控制对用户输入的响应方式, 是根据对响应方式和响应流程的定义而获得的对象。根据不同的 MVC 通信设计, 控制器对象可以与模型对象、视图对象进行不同形式的通信。

针对不同的情况, 控制器对象通常有两种实现方法: ( 1) 采用的设计开发环境提供了对控制器的支持, 对控制器对象的实现形式以及它与模型对象和视图对象的交互方法提供了专门的支持, 如在采用 JSP/ Servlet/ Java 方式进行开发时, Servlet 对象充当了控制器对象的角色, 并且有相应的方法支持与 JSP 和用Java 实现的模型对象进行通信。( 2) 控制器作为模型和视图之间的一个去耦层实现, 表现为一些普通对象, 但完成去耦功能。

4. MVC的实现技术

实现MVC 模式时面对的主要问题是 Model 与 View 的关系, 这可以使用 Observer 模式来实现。为了满足分布式的要求, 可以使用 Proxy 模式来封装本地操作和远程。

4.1 相关模式: Observer( 观察者)

Observer 模式用于描述 Model 与 View 的更新、访问关系。它定义了对象间的一种一对多的依赖关系, 当一个对象的状态发生改变时, 所有依赖于它的对象都得到通知并被自动更新,所以又称为依赖( Dependents) 。这一模式中的关键对象是目标( Subject) 和观察者( Observer) , 一个目标可以有任意数目的依赖它的观察者。一旦目标的状态发生改变, 所有的观察者都得到通知, 作为对这个通知的响应, 每个观察者都将查询目标以使其状态与目标的状态同步, 这种交互也称为发布- 订阅 (Publish Subscribe) 。目标是通知的发布者, 它发出通知时并不需知道谁是它的观察者, 可以有任意数目的观察者订阅并接收通知。例如, 如果一个操作涉及到对几个相互依赖的目标进行改动, 就必须保证仅在所有的目标都已更改完毕后, 才一次性地通知它们的观察者, 而不是每个目标都通知观察者。另外, 观察者通常并不对所有事件都感兴趣, 可以扩展目标的注册接口, 让各观察者注册为仅对特定事件感兴趣, 以提高更新的效率。当一个事件发生时, 目标仅通知那些已注册为对该事件感兴趣的观察者。支持这种做法的一种途径是使用目标对象的方面( As pects) 的概念, 这样就可以实现不同的观察粒度。可以在将Observer 添加到 Subject 上时使用 Aspect 作为参数, 将观察者对象注册为对目标对象的某特定事件感兴趣, 通知时将这方面的改变作为 U pdate 操作的一个参数提供给它的观察者。

2 相关模式: Proxy( 代理)

为了实现分布式体系, 需要区分是远程操作还是本地操作, 这种区分如果体现在功能代码中就会影响代码的清晰度, 而且不便于维护。面向对象设计的一个思想就是“封装变化”, 即把易变化的部分封装在一个类中,

这样结构清晰。Proxy就使用这样一个机制, 使得功能代码编写时可以不考虑是本地操作还是远程操作。

5. MVC模式的应用

由于具有使用户界面( View ) 、控制 ( Controller ) 与数据(Model) 分离开来的特性, MVC很适用于大型的 GUI 软件的开发。目前许多 GU I 软件的结构都是基于或者是部分地基于 MVC 的。一些比较常见的例子如下:

(1) Microsoft Foundation Class( MFC) 的基本结构是文档/视图结构, 它是 MVC 结构的变体。它把 View 和 Controller 集成在视图内, 文档负责数据的表示以及存取( Model) , 视图负责显示文档内容 ( View ) 以及处理用户界面上的操作( Controller ) 。一个文档可以对应多个视图, 每个视图可以采取不同的表现方式, 如同一份数据, 可以在一个视图中使用文本方式显示, 一个视图中使用表格方式显示, 另一个视图使用图表的方式显示。当用户在某一个视图中改变了文档的内容, 可以使用UpdateAllViews( )方法发消息给该

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[442852],资料为PDF文档或Word文档,PDF文档可免费转换为Word

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。