`
jinghuainfo
  • 浏览: 1527826 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Model-View-Control

 
阅读更多

Java BluePrints

Model-View-Controller

Context

Application presents content to users in numerous pages containing various data. Also, the engineering team responsible for designing, implementing, and maintaining the application is composed of individuals with different skill sets.

Problem

Now, more than ever, enterprise applications need to support multiple types of users with multiple types of interfaces. For example, an online store may require an HTML front for Web customers, a WML front for wireless customers, a JavaTM (JFC) / Swing interface for administrators, and an XML-based Web service for suppliers

Context Diagram

When developing an application to support a single type of client, it is sometimes beneficial to interweave data access and business rules logic with interface-specific logic for presentation and control. Such an approach, however, is inadequate when applied to enterprise systems that need to support multiple types of clients. Different applications need to be developed, one to support each type of client interface. Non-interface-specific code is duplicated in each application, resulting in duplicate efforts in implementation (often of the copy-and-paste variety), as well as testing and maintenance. The task of determining what to duplicate is expensive in itself, since interface-specific and non-interface-specific code are intertwined. The duplication efforts are inevitably imperfect. Slowly, but surely, applications that are supposed to provide the same core functionality evolve into different systems.

Forces

  • The same enterprise data needs to be accessed when presented in different views: e.g. HTML, WML, JFC/Swing, XML

  • The same enterprise data needs to be updated through different interactions: e.g. link selections on an HTML page or WML card, button clicks on a JFC/Swing GUI, SOAP messages written in XML

  • Supporting multiple types of views and interactions should not impact the components that provide the core functionality of the enterprise application

Solution

By applying the Model-View-Controller (MVC) architecture to a JavaTM 2 Platform, Enterprise Edition (J2EETM) application, you separate core business model functionality from the presentation and control logic that uses this functionality. Such separation allows multiple views to share the same enterprise data model, which makes supporting multiple clients easier to implement, test, and maintain.

Structure

The following diagram represents the Model-View-Controller pattern:

Interaction Diagram

Participants & Responsibilities

The MVC architecture has its roots in Smalltalk, where it was originally applied to map the traditional input, processing, and output tasks to the graphical user interaction model. However, it is straightforward to map these concepts into the domain of multi-tier enterprise applications.

  • Model - The model represents enterprise data and the business rules that govern access to and updates of this data. Often the model serves as a software approximation to a real-world process, so simple real-world modeling techniques apply when defining the model.
  • View -The view renders the contents of a model. It accesses enterprise data through the model and specifies how that data should be presented. It is the view's responsibility to maintain consistency in its presentation when the model changes. This can be achieved by using a push model, where the view registers itself with the model for change notifications, or a pull model, where the view is responsible for calling the model when it needs to retrieve the most current data.
  • Controller - The controller translates interactions with the view into actions to be performed by the model. In a stand-alone GUI client, user interactions could be button clicks or menu selections, whereas in a Web application, they appear as GET and POST HTTP requests. The actions performed by the model include activating business processes or changing the state of the model. Based on the user interactions and the outcome of the model actions, the controller responds by selecting an appropriate view.

Strategies

  • Web-based clients such as browsers. JavaServer PagesTM (JSPTM) pages to render the view, Servlet as the controller, and Enterprise JavaBeansTM (EJBTM) components as the model. The Java Pet Store sample application illustrates this strategy.

  • Centralized controller. Instead of having multiple servlets as controllers, a main Servlet is used to make control more manageable. The Front Controller pattern describes this strategy in more detail.

  • Wireless clients such as cell phones. The Smart Ticket sample application illustrates this strategy.

Consequences

  • Re-use of Model components. The separation of model and view allows multiple views to use the same enterprise model. Consequently, an enterprise application's model components are easier to implement, test, and maintain, since all access to the model goes through these components.

  • Easier support for new types of clients. To support a new type of client, you simply write a view and some controller logic and wire them into the existing enterprise application.

  • Increased design complexity. This pattern introduces some extra classes due to the separation of model, view, and controller.

Related Patterns

[BRMSS96]: Presentation-Abstraction-Control defines a structure with a hierarchy or cooperating agents, each with specific duties of the application functionality. It divides the functionality responsibilities into three components: presentation, abstraction, and control.


© 2000-2002 Sun Microsystems, Inc. All Rights Reserved.

<script language="JavaScript" src="/js/omi/jsc/s_code_remote.js" type="text/javascript"></script>
分享到:
评论

相关推荐

    WEBMVC开发

    (1) 实现一个MVC模式的Web应用(内容不限,比如登陆、查询(成绩、商品、人员信息)、录入(成绩、商品、人员信息)等)。 采用JSP编写一个页面(考虑美学设计),输入相关信息,提交给Servlet,Servlet通过调用...

    Introduction to Model View Control (MVC)

    Introduction to Model View Control (MVC) using in C#

    基于Java+Mysql的图书管理系统设计.zip

    资源包含文件:设计报告...(5)设计模式:理解并使用MVC(Model-View-Control)的设计模式进行系统结构的设计; 详细介绍参考:https://biyezuopin.blog.csdn.net/article/details/123324030?spm=1001.2014.3001.5502

    J2EE体系架构分析(珍藏版)

    模型-视图-控制(model-view-control,简称MVC)结构是目前最常见的J2EE应用所基于的体系结构,MVC主要适用于交互式的Web应用,尤其是存在大量页面及多次客户访问及数据显示;相比较而言,一个工作流体系结构更多应用...

    J2EE体系结构设计

    模型-视图-控制(model-view-control,简称MVC)结构是目前最常见的J2EE应用所基于的体系结构,MVC主要适用于交互式的Web应用,尤其是存在大量页面及多次客户访问及数据显示;相比较而言,一个工作流体系结构更多应用...

    GEF 入门操作

    GEF的优势是提供了标准的MVC(Model-View-Control)结构,开发人员可以利用GEF来完成以上这些功能,而不需要自己重新设计。与 其他一些MVC编辑框架相比,GEF的一个主要设计目标是尽量减少模型和视图之间的依赖,...

    计算机论文

    本系统采用MVC(model-view-control)三层架构的模式,在开发过程中会使用到Struts和Hibernate来处理页面的逻辑和对象的持久化工作。本系统开发并没有单纯的使用JSP+Servlet进行,而是结合了Struts和Hibernate,使得...

    springmvc教程

    springmvc经典教程1.MVC:Model-View-Control框架性质的C层要完成的主要工作:封装web请求为一个数据对象、调用业务逻辑层来处理数据对象、返回处理数据结果及相应的视图给用户。2.简要概述springmvcSpring C 层框架...

    网上招聘系统客户端系统测试报告.doc

    Model-View-Control(模式-视图-控制)的缩写,表示一个三层的结构体系。 1.4术语定义 OnlineCV 网上招聘系统的项目编号。 LoadRunner Mercury Interactive的一个对Windows和UniX环境的负载...

    基于Java EE的图书管理系统的设计与实现

    设计模式:使用MVC(Model-View-Control)的设计模式进行系统结构的设计; 下面展示一部分资源: 图书管理系统开发文档 一、引言 一直以来,图书管理一直是经过人工进行书籍查询、借阅等环节,人力资源消耗很大,...

    基于Java实现(MVC)图书管理系统【100010001】

    设计模式:理解并使用MVC(Model-View-Control)的设计模式进行系统结构的设计; 系统用户分为:借阅者(学生、教师及其他用户)、管理员 借阅者的主要功能: 个人信息管理:查看、修改个人基本信息; 查询图书、...

    mvc设计模式

    MVC设计模式是一个存在于服务器表达层的模型,它将应用分开,改变应用之间的高度耦合,其中MVC是 Model-View-Control 的简称,即模型-视图-控制器

    MVC+Servlet(含sql).zip

    使用 MVC 三层架构模式,Model - View - Control , 顶层为接口-抽象类-实现类,Servlet 作为原始的控制器,数据库层 使用 原生的sql , 双重锁单例模式 提供公共类. 含sql 脚本

    model view_View_QT_mvc_control_model_

    model/view framework; MVC Pattern in Qt; QListWidget

    用C#实现MVC(ModelViewControl)模式介绍

    益处 在我们的开发项目中使用MVC(Model-View-Control)模式的益处是,可以完全降低业务层和应用表示层的相互影响。此外,我们会有完全独立的对象来操作表示层。MVC在我们项目中提供的这种对象和层之间的独立,将使...

    基于java的学籍管理系统

    在本次系统的开发中我们选用J2EE三层结构,在中间应用层开发中,采用以EJB为中心、Servlets做控制、JSP负责呈现逻辑的MVC(Model-View-Control)结构,提高了W eb应用程序的可扩展性和可维护性。

    Spring MVC学习指南

    以下这个学习案例是我最近学习Spring MVC时跟从一本 书上的示例,原文中的示例代码有一些小错误,不过我 在调试的过程中已经给予了...对于现有较成熟的Model-View-Control(MVC)框架而言, 其解决的主要问题无外乎下

    毕业设计降低源码的重复率-snake:贪吃蛇项目

    毕业设计降低源码的重复率 ...Model完全独立,View 是 Model 的状态机,Model 与 View 都由 Control 来驱动。 Model 看一张贪吃蛇的经典图片。 贪吃蛇有四个关键的参与对象: 蛇(snake) 食物(food) 墙(bound

    9.1 MVC 、MVP 讲解

    经过了这么多年的发展,当然会演变出不同的版本,但核心没变依旧还是三层模型Model-View-Control。 可能由于MVP、MVVM的兴起,MVC在android中的应用变得越来越少了,但MVC是基础,理解好MVC才能更好的理解MVP,MVVM。...

Global site tag (gtag.js) - Google Analytics