`

表示层模式:Composite View—复合视图模式

阅读更多

Context
Sophisticated Web pages present content from numerous data sources, using multiple
subviews that comprise a single display page. Additionally, a variety of individuals with
different skill sets contribute to the development and maintenance of these Web pages.
Problem
Instead of providing a mechanism to combine modular, atomic portions of a view into
a composite whole, pages are built by embedding formatting code directly within each view.
Modification to the layout of multiple views is difficult and error prone, due to the
duplication of code.
Forces
Atomic portions of view content change frequently.
Multiple composite views use similar subviews, such as a customer inventory table.
These atomic portions are decorated with different surrounding template text, or they appear
in a different location within the page.
Layout changes are more difficult to manage and code harder to maintain when
subviews are directly embedded and duplicated in multiple views.
Embedding frequently changing portions of template text directly into views also
potentially affects the availability and administration of the system. The server may need to
be restarted before clients see the modifications or updates to these template components.
Solution
Use composite views that are composed of multiple atomic subviews. Each
component of the template may be included dynamically into the whole and the layout of
the page may be managed independently of the content.
This solution provides for the creation of a composite view based on the inclusion
and substitution of modular dynamic and static template fragments. It promotes the reuse of
atomic portions of the view by encouraging modular design. It is appropriate to use a
composite view to generate pages containing display components that may be combined in
a variety of ways. This scenario occurs, for example, with portal sites that include numerous
independent subviews, such as news feeds, weather information, and stock quotes on a
single page. The layout of the page is managed and modified independent of the subview
content.
Another benefit of this pattern is that Web designers can prototype the layout of a site,
plugging static content into each of the template regions. As site development progresses,
the actual content is substituted for these placeholders.
This pattern is not without its drawbacks. There is a runtime overhead associated with
it, a tradeoff for the increased flexibility that it provides. Also, the use of a more
sophisticated layout mechanism brings with it some manageability and development issues,
since there are more artifacts to maintain and a level of implementation indirection to
understand.

分享到:
评论

相关推荐

    软件架构模式的种类 三种模式

    4. **Composite(组合)模式**:此模式允许开发者将对象组合成树形结构以表示“部分-整体”的层次结构。Composite 模式使得用户可以统一地处理单个对象和组合对象,适用于需要表示对象的层次结构的情况。 5. **...

    ASP.NET设计模式-杨明军译(源码)

    第8章 表示层 8.1 反转控制 8.1.1 Factory Method设计模式 8.1.2 Service Locator 8.1.3 IoC容器 8.1.4 StructureMap 8.2 Model-View-Presenter 8.3 Front Controller 8.3.1 Command模式 8.3.2 Chain of ...

    J2EE Patterns

    - **复合视图**(Composite View):组合多个视图组件。 - **服务到工作者**(Service To Worker):将任务分配给后台线程处理。 - **调度视图**(Dispatcher View):负责分发视图更新。 #### 业务层模式 - **...

    设计模式.docx

    模型-视图-控制器(Model-View-Controller)模式将应用程序分为三个基本部分:模型、视图和控制器。这种模式有助于分离业务逻辑与表现层。 #### 业务代表模式(Business Delegate Pattern) 业务代表模式用于封装...

    Design Patterns Workbook 英文版 (pdf)

    - **模型-视图-控制器模式**:在Java Web开发中,MVC模式是构建应用程序的标准模式之一,可以清晰地划分业务逻辑、数据和表示层。 - **中介者模式**:在处理多表关联或多实体关系时,使用中介者模式可以有效地维持...

    JSF框架中使用的设计模式介绍

    MVC模式的主要目的是分离表示层与业务逻辑。JSF使用MVC模式来管理页面显示和后端逻辑之间的关系。当用户请求一个JSF页面时,FacesServlet作为前端控制器接收请求并处理它。JSF采用MVC模式的一个变体,在这个变体中,...

    Wireshark 主界 面的操作菜单

    **专家信息复合(Expert Info Composite)**:提供关于选定数据包的更复杂的诊断信息。 **统计(Statistics)**:显示关于捕获数据的各种统计信息。 **概要(Summary)**:显示有关当前捕获会话的总体统计信息。 **协议...

    Android源码学习之组合模式定义及应用

    在Android源码中,组合模式被广泛应用于构建可扩展的、层次化的组件,例如在视图系统中,ViewGroup与View之间的关系就体现了这种模式。 **组合模式的核心概念:** 1. **Component(抽象组件)**:这是组合模式的...

    英语词汇0920-2018.doc

    32. **Presentation Layer**:表示层,OSI模型的第6层,负责数据的加密、解密、压缩和解压等任务。 33. **ARP (Address Resolution Protocol)**:地址解析协议,用于将IP地址转换为MAC地址,实现局域网内的通信。 ...

    2014—SHH面试题

    MVC(Model-View-Controller)模式是软件设计中的一个经典模式,用于分离业务逻辑、数据和用户界面。在SSH框架中,Struts扮演了Controller的角色,Spring作为整体的IoC(Inversion of Control,控制反转)和DI...

    jsf 电子书合集(来源于网络)

    2. **Facelets**:JSF 2.0引入的新视图技术,替代了JSP作为默认的视图表示语言,提供了更清晰的结构和组件化开发能力。 3. **EL (Expression Language)**:JSF中用于在视图层绑定数据和方法的表达式语言,用于访问...

    marionette-cats:管理猫的牵线木偶应用程序示例

    4. **View与ItemView**: 视图(View)是用户界面的表示层,负责渲染和更新DOM。ItemView是Marionette中的基础视图类型,通常用于显示单个数据项,如列表中的每一项猫的信息。 5. **CompositeView与CollectionView**...

    SWT-JFace-3.5-API.chm

    2. 表格视图:JFace的TableViewer提供了更高级的表格操作,如排序、过滤、分页等功能,使表格处理更加灵活。 3. 对话框:JFace的Dialog类提供了一组标准对话框,如MessageDialog、InputDialog和FileDialog,简化了...

    DXDesigner教程

    - **视窗工具栏**:通过`View`菜单中的`View Toolbar`选项,可以启用一个包含视图控制工具的工具栏,提供与菜单相同的视图操作功能。 #### 三、元器件的种类与添加 ##### 1. 元器件类型 - **Module**:这类元器件...

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

    日期类型 date 7字节 用于存储表中的日期和时间数据,取值范围是公元前4712年1月1日至公元9999年12月31日,7个字节分别表示世纪、年、月、日、时、分和秒 二进制数据类型 row 1~2000字节 可变长二进制数据,在具体...

    超级有影响力霸气的Java面试题大全文档

     对于客户机,EntityBean是一种持久性对象,它代表一个存储在持久性存储器中的实体的对象视图,或是一个由现有企业应用程序实现的实体。  Session Bean 还可以再细分为 Stateful Session Bean 与 Stateless ...

Global site tag (gtag.js) - Google Analytics