`

表示层模式:Service to Worker—工作者服务模式

阅读更多

Context
The system controls flow of execution and access to business data, from which it
creates presentation content.
Note
The Service to Worker pattern, like the Dispatcher View pattern, describes a common
combination of other patterns from the catalog. Both of these macro patterns describe the
combination of a controller and dispatcher with views and helpers. While describing this
common structure, they emphasize related but different usage patterns.
Problem
The problem is a combination of the problems solved by the Front Controller and
View Helper patterns in the presentation tier. There is no centralized component for
managing access control, content retrieval, or view management, and there is duplicate
control code scattered throughout various views. Additionally, business logic and
presentation formatting logic are intermingled within these views, making the system less
flexible, less reusable, and generally less resilient to change.
Intermingling business logic with view processing also reduces modularity and
provides a poor separation of roles among Web production and software development
teams.
Forces
Authentication and authorization checks are completed per request.
Scriptlet code within views should be minimized.
Business logic should be encapsulated in components other than the view.
Control flow is relatively complex and based on values from dynamic content.
View management logic is relatively sophisticated, with multiple views potentially
mapping to the same request.
Solution
Combine a controller and dispatcher with views and helpers (see "Front Controller"
on page 172 and "View Helper" on page 186) to handle client requests and prepare a
dynamic presentation as the response. Controllers delegate content retrieval to helpers,
which manage the population of the intermediate model for the view. A dispatcher is
responsible for view management and navigation and can be encapsulated either within a
controller or a separate component.
Service to Worker describes the combination of the Front Controller and View Helper
patterns with a dispatcher component.
While this pattern and the Dispatcher View pattern describe a similar structure, the
two patterns suggest a different division of labor among the components. In Service to
Worker, the controller and the dispatcher have more responsibilities.
Since the Service to Worker and Dispatcher View patterns represent a common
combination of other patterns from the catalog, each warrants its own name to promote
efficient communication among developers. Unlike the Service to Worker pattern, the
Dispatcher View pattern suggests deferring content retrieval to the time of view processing.
In the Dispatcher View pattern, the dispatcher typically plays a limited to moderate
role in view management. In the Service to Worker pattern, the dispatcher typically plays a
moderate to large role in view management.
A limited role for the dispatcher occurs when no outside resources are utilized in
order to choose the view. The information encapsulated in the request is sufficient to
determine the view to dispatch the request. For example,
http://some.server.com/servlet/Controller?next=login.jsp
The sole responsibility of the dispatcher component in this case is to dispatch to the
view login.jsp.
An example of the dispatcher playing a moderate role is the case where the client
submits a request directly to a controller with a query parameter that describes an action to
be completed:
http://some.server.com/servlet/Controller?action=login
The responsibility of the dispatcher component here is to translate the logical name
login into the resource name of an appropriate view, such as login.jsp, and dispatch to that
view. To accomplish this translation, the dispatcher may access resources such as an XML
configuration file that specifies the appropriate view to display.
On the other hand, in the Service to Worker pattern, the dispatcher might be more
sophisticated. The dispatcher may invoke a business service to determine the appropriate
view to display.
The shared structure of Service to Worker and Dispatcher View consists of a
controller working with a dispatcher, views, and helpers.

分享到:
评论

相关推荐

    ThinkPHP3.2 集成 php-resque: PHP Resque Worker

    $worker = new Resque\Worker($this->queues); $worker->logLevel = $logLevel; fwrite(STDOUT, '*** Starting worker ' . $worker . "\n"); $worker->work($interval); break; } } } } // Start a single ...

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

    第26章 PROXY模式和STAIRWAY TO HEAVEN模式:管理第三方API 第27章 案例研究:气象站 第六部分 ETS案例研究 第28章 VISITOR模式 第29章 STATE模式 第30章 ETS框架 附录 附录A UML表示法I:CGI示例 附录B UML表示法...

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

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

    c++ 建造者模式实例

    建造者模式: 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表现。这就是建造者模式。 建造者模式可以把一个产品的内部表象与产品的生成过程分隔开来,从而可以使一个建造过程就可以生成...

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

    单例模式:某个类只能有一个实例,提供一个全局的...责任链模式:将请求的发送者和接收者解耦,使的多个对象都有处理这个请求的机会。 迭代器模式:一种遍历访问聚合对象中各个元素的方法,不暴露该对象的内部结构。

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

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

    JavaEE设计模式之表示层模式

    因为表示层是请求驱动的,所以“用户”可以是任意请求的发起者。控制器处理该请求。模型就是业务数据,而视图就是最终发生的应答。控制器是与请求发生联系的起点。控制器就是一个主管,首先规划要做哪些更新和要显示...

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

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

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

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

    edimar-portfolio::construction_worker:电工组合

    :construction_worker: Edimar投资组合 这是电工的网络产品组合 使用的技术 HTML CSS -Javascript Nodejs的 表示 节点邮件程序 运行项目 要运行该项目,请按照以下说明进行操作: $ npm i $ npm run dev $ abrir ...

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

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

    GoF 的 23 种设计模式

    适配器(Adapter)模式:将一个类的接口转换成客户希望的另外一个接口,使得原本由于接口不兼容而不能一起工作的那些类能一起工作。 桥接(Bridge)模式:将抽象与实现分离,使它们可以独立变化。它是用组合关系...

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

    在 Spring 中,观察者模式广泛应用于事件驱动编程中,例如,在 Spring MVC 中,使用观察者模式来处理请求和响应。 4.MVC Pattern:模型视图控制器模式,分离应用程序的关注点,实现高内聚、低耦合的设计。 在 ...

    表示层设计模式:在ASP.NET中实现PageController

    本页内容上下文实现策略测试考虑事项结果上下文相关模式 上下文您要在ASP.NET中构建Web应用程序,您希望通过使用内置的PageController(页面控制器)来利用ASP.NET的事件驱动特性。返回页首 实现策略默认情况下,...

    软件设计模式实验2结构型模式源码

    3.装饰者模式:这是一个关于相亲的故事。某家有女初长成,七大姑八大姨欲帮忙寻得佳婿,后在各种群、圈、网站,收集了各种男人的资料。这里需要一个应用程序生成收集过来的男人的描述,如..........4.组合模式:用...

    实用J2EE设计模式编程指南

    第2章 Web层设计模式 表示模式 案例:宾馆订房管理系统 标识模式 小结 第3章 持久性框架设计模式 开始模型 何谓持久性框架 TitleDAO会话Bean Value Object模式 Service Locator模式 使用持久性框架 持久性框架...

    33种JAVA设计模式DEMO

    创建型模式 这些设计模式提供了一种在创建对象的同时隐藏创建逻辑的方式,而不是使用 new 运算符直接实例化对象。...服务定位器模式(Service Locator Pattern) 传输对象模式(Transfer Object Pattern)

    251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》.rar

    251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》 251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》

Global site tag (gtag.js) - Google Analytics