`

表示层模式: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.

分享到:
评论

相关推荐

    设计模式之组合模式(Composite Pattern)

    将对象组合成树形结构以表示“部分-整体”的层次结构。它使得客户对单个对象和复合对象的使用具有一致性。

    敏捷软件开发:原则、模式与实践

    第23章 COMPOSITE模式 第24章 OBSERVER模式—回归为模式 第25章 ABSTRACT SERVER模式、ADAPTER模式和BRIDGE模式 第26章 PROXY模式和STAIRWAY TO HEAVEN模式:管理第三方API 第27章 案例研究:气象站 第六部分 ETS...

    关于设计模式MVC(Model View Controller)模型-视图-控制器

     模型-视图-控制器(MVC)是Xerox PARC在八十年代为编程语言Smalltalk-80发明的一种软件设计模式,至今已被广泛使用。最近几年被推荐为Sun公司J2EE平台的设计模式,并且受到越来越多的使用 ColdFusion 和 PHP 的...

    CompositePattern:复合设计模式示例

    复合图案复合图案的例子当我们需要以类似的方式将一组对象视为单个对象时,使用复合模式。 合成模式以树结构的形式构成对象,以表示部分以及整个层次结构。 这种设计模式属于结构模式,因为该模式创建了一组对象的树...

    JavaEE设计模式之表示层模式

    控制器就是一个主管,首先规划要做哪些更新和要显示什么视图,然后调用被选择的模式和视图以执行真正的规划。模型的工作是管理对该状态的访问,为控制器和视图提供统一的接口。视图从模型中读取数据,并使用这些数据...

    23种设计模式入门到精通详解.txt

    组合模式:将对象组合成树形结构以表示“”部分-整体“”的层次结构。 装饰模式:动态的给对象添加新的功能。 代理模式:为其他对象提供一个代理以便控制这个对象的访问。 亨元(蝇量)模式:通过共享技术来有效...

    Java EE设计模式:Spring企业级开发最佳实践

    4.MVC Pattern:模型视图控制器模式,分离应用程序的关注点,实现高内聚、低耦合的设计。 在 Spring 中,MVC 模式是框架的核心部分,提供了一个松耦合的架构,开发者可以根据需要选择不同的视图技术和模型来实现...

    组合模式 Composite Pattern

    组合模式(Composite Pattern),又叫部分整体模式,是用于把一组相似的对象当作一个单一的对象。组合模式依据树形结构来组合对象,用来表示部分以及整体层次。这种类型的设计模式属于结构型模式,它创建了对象组的...

    Python 程序语言设计模式思路-结构型模式:组合模式:将对象组合成树形结构

    组合模式作为一种强大的设计模式,通过将对象组合成树形结构,可以表示“部分-整体”的层次结构,并统一地处理单个对象和组合对象,简化了客户端代码的复杂性,从而提高代码的灵活性和可扩展性。在实际开发中,它在...

    GoF 的 23 种设计模式

    组合(Composite)模式:将对象组合成树状层次结构,使用户对单个对象和组合对象具有一致的访问性。 模板方法(TemplateMethod)模式:定义一个操作中的算法骨架,而将算法的一些步骤延迟到子类中,使得子类可以不...

    组合模式(Composite Pattern)原理图

    组合模式(Composite Pattern)是一种对象结构型模式,其定义是将多个对象组合成树形结构以表示“整体-部分”关系的层次结构。它使得客户端对单个对象和组合对象的使用具有一致性。在组合模式中,对象被组织成树形...

    浅析23种软件设计模式

    15. 解释器模式:解释器模式的主要思想是给定一个语言后,可以定义出其文法的一种表示,并同时提供一个解释器。这种模式的优点是可以使客户端使用这个解释器来解释这个语言中的句子,但缺点是增加了系统的复杂度。 ...

    快速学习C++设计模式:观察者模式实例代码

    观察者模式是目前应用最广、影响范围最大的模式之一,因为 Observer 的一个实例 MVC结构(Model/View/Control )在系统开发架构设计中有着很重要的地位和意义,实现了业务逻辑和表示层的解耦。下面示例代码以篮球...

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

    5.2.2 Composite模式 5.2.3 Layer Supertype模式 5.3 应用设计原则 5.3.1 依赖倒置原则和依赖注入模式 5.3.2 接口分离原则 5.3.3 里氏替换原则 5.4 小结 第6章 服务层 6.1 服务层介绍 6.1.1 SOA 6.1.2 ...

    表示层设计模式:InterceptingFilter(截取筛选器)

    本页内容上下文问题影响因素解决方案变体示例结果上下文相关模式致谢 上下文对于任何一个曾经从头建立Web应用程序的人来说,他们都会有这样的体会:这项任务所需要的独立完成的工作量要比建立内部客户端-服务器应用...

    工厂模式三层结构示例项目源码

    CodematicDemoF3 是一个基于工厂模式的三层架构示例项目源码,基于VS2005 SP1开发(如果没有装SP1,web项目会打不开),结构更简洁,提供更多有效的示例源码参考。方便用户更好的理解和使用该架构进行开发,配合动软...

    MFC 如何将一个对话框嵌入到视图中

    MFC 将对话框嵌入视图的实现方法 MFC(Microsoft Foundation Classes)是一个功能强大且广泛使用的应用程序框架,在视图控件中嵌入对话框是常见的需求。下面将详细介绍如何将一个对话框嵌入到视图中,实现自定义的...

    网站生成器-工厂模式开发,用于页面表示层

    网站开发的一层 二层开发完成之后,所有的页面表示层都可以用此软件来生成。这是我们开发时自己开发的软件。绝对好用。提高工作效率。

    C MVC框架libgitlmvc.zip

    View<====>Front Controller<====>Commands<====>Model该框架包括四个部分: 视图: 用户交互界面 前端控制其(Front Controller): 处理所有的视图请求 命令: 前端控制其根据不同的视图请求,调用不同的命令,实现...

Global site tag (gtag.js) - Google Analytics