`
jinghuainfo
  • 浏览: 1557220 次
  • 性别: 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>
分享到:
评论

相关推荐

    MVVM(Model-View-ViewModel)实例讲解

    MVVM(Model-View-ViewModel)是一种设计模式,主要用于构建用户界面,特别是在WPF(Windows Presentation Foundation)和Silverlight应用程序中。它源自于MVC(Model-View-Controller)模式,但针对UI开发进行了...

    WEBMVC开发

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

    Introduction to Model View Control (MVC)

    **模型-视图-控制器**(Model-View-Controller,简称MVC)是一种广泛应用于软件工程中的设计模式,特别是面向对象编程语言如C#中,用于构建可扩展、易于维护的应用程序。其核心思想是将应用程序分为三个主要部分:...

    音频播放器软件的设计与实现.doc

    摘要:本文探索性地设计实现了一个支持播放列表和LRC歌词实时显示的音频播放器的软件,该软件使用Eclipse 3.2平台、Java语言及其相应的音频支持插件JMF开发而成,设计思想为MVC,即Model-View-Control模式。...

    基于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应用,尤其是存在大量页面及多次客户访问及数据显示;相比较而言,一个工作流体系结构更多应用...

    音频播放器软件的设计与实现-毕业论文.doc

    该软件使用Eclipse3.2平台,java语言及其相应的音频支持插件JMF开发而成,设计思想为MVC,即Model-View-Control模式。 在设计和实现音频播放器软件之前,需要了解java语言、MVC和JMF的基本概念。Java语言是一种面向...

    网上招聘系统客户端系统测试报告.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)的设计模式进行系统结构的设计; 系统用户分为:借阅者(学生、教师及其他用户)、管理员 借阅者的主要功能: 个人信息管理:查看、修改个人基本信息; 查询图书、...

    model view_View_QT_mvc_control_model_

    在IT行业中,模型-视图-控制器(Model-View-Controller,MVC)模式是一种广泛应用于软件设计,尤其是用户界面设计的架构模式。Qt库,一个跨平台的应用开发框架,也支持并实现了这一模式。本篇文章将深入探讨“model/...

    网上人才招聘系统的设计与实现(论文)设计.pdf

    在具体实现技术上,该系统采用了B/S架构(Browser/Server,即浏览器/服务器模式),通过Model-View-Control(模型-视图-控制器)设计模式进行开发,确保了系统的分层和模块化设计,提高了系统的可维护性和扩展性。...

    旧书在线交易系统可行性分析报告.pdf

    技术方面,项目采用MVC(Model-View-Control)架构设计。MVC模式将应用分为模型、视图和控制器三层,降低了各组件间的耦合性。模型负责存储应用状态,通常与数据库交互;视图呈现用户界面,展示模型中的数据;控制器...

    Liferay_Control-Panel_Portlet DTD-5.2_MVC-Portlet

    本主题主要关注Liferay中的"Control-Panel Portlet"、"DTD 5.2"以及"MVC Portlet"这三大核心概念。 首先,我们来理解"Liferay Control Panel"。控制面板是Liferay系统的核心管理界面,它提供了对站点、用户、角色、...

    MVC+Servlet(含sql).zip

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

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

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

    GEF研究总结

    GEF的核心是其Model-View-Control(MVC)架构。在该架构中: - **模型(Model)**:与视图无关,仅与控制器交互。模型的变化通过事件机制通知控制器,控制器再负责更新视图。通常,模型会包含一些辅助类,如用于...

    UML停车场管理系统

    - **设计模式**:采用MVC架构,即Model-View-Control,将数据逻辑、业务逻辑和视图分离。 - **技术栈**:使用Struts 1.2 + Hibernate 3.1组合进行系统开发。 #### 六、系统设计过程 ##### 6.1 总体设计 - **身份...

    GEF基础知识

    GEF遵循经典的MVC(Model-View-Control)架构模式,各部分的作用如下: - **Model(模型)**:这部分是由开发者根据具体的业务需求来设计的,需要提供一种模型变更通知的机制,以便在模型发生变化时通知控制器。 - ...

Global site tag (gtag.js) - Google Analytics