Context
In a Java 2 Platform, Enterprise Edition (J2EE) application, the server-side business
components are implemented using session beans, entity beans, DAOs, and so forth.
Application clients frequently need to access data that is composed from multiple objects.
Problem
Application clients typically require the data for the model or parts of the model to
present to the user or to use for an intermediate processing step before providing some
service. The application model is an abstraction of the business data and business logic
implemented on the server side as business components. A model may be expressed as a
collection of objects put together in a structured manner (tree or graph). In a J2EE
application, the model is a distributed collection of objects such as session beans, entity
beans, or DAOs and other objects. For a client to obtain the data for the model, such as to
display to the user or to perform some processing, it must access individually each
distributed object that defines the model. This approach has several drawbacks:
Because the client must access each distributed component individually, there is a
tight coupling between the client and the distributed components of the model over the
network
The client accesses the distributed components via the network layer, and this can
lead to performance degradation if the model is complex with numerous distributed
components. Network and client performance degradation occur when a number of
distributed business components implement the application model and the client directly
interacts with these components to obtain model data from that component. Each such
access results in a remote method call that introduces network overhead and increases the
chattiness between the client and the business tier.
The client must reconstruct the model after obtaining the model's parts from the
distributed components. The client therefore needs to have the necessary business logic to
construct the model. If the model construction is complex and numerous objects are
involved in its definition, then there may be an additional performance overhead on the
client due to the construction process. In addition, the client must contain the business logic
to manage the relationships between the components, which results in a more complex,
larger client. When the client constructs the application model, the construction happens on
the client side. Complex model construction can result in a significant performance
overhead on the client side for clients with limited resources.
Because the client is tightly coupled to the model, changes to the model require
changes to the client. Furthermore, if there are different types of clients, it is more difficult
to manage the changes across all client types. When there is tight coupling between the
client and model implementation, which occurs when the client has direct knowledge of the
model and manages the business component relationships, then changes to the model
necessitate changes to the client. There is the further problem of code duplication for model
access, which occurs when an application has many types of clients. This duplication makes
client (code) management difficult when the model changes.
Forces
Separation of business logic is required between the client and the server-side
components.
Because the model consists of distributed components, access to each component is
associated with a network overhead. It is desirable to minimize the number of remote
method calls over the network.
The client typically needs only to obtain the model to present it to the user. If the
client must interact with multiple components to construct the model on the fly, the
chattiness between the client and the application increases. Such chattiness may reduce the
network performance.
Even if the client wants to perform an update, it usually updates only certain parts of
the model and not the entire model.
Clients do not need to be aware of the intricacies and dependencies in the model
implementation. It is desirable to have loose coupling between the clients and the business
components that implement the application model.
Clients do not otherwise need to have the additional business logic required to
construct the model from various business components.
Solution
Use a Transfer Object Assembler to build the required model or submodel. The
Transfer Object Assembler uses Transfer Objects to retrieve data from various business
objects and other objects that define the model or part of the model.
The Transfer Object Assember constructs a composite Transfer Object that represents
data from different business components. The Transfer Object caries the data for the model
to the client in a single method call. Since the model data can be complex, it is
recommended that this Transfer Object be immutable. That is, the client obtains such
Transfer Objects with the sole purpose of using them for presentation and processing in a
read-only manner. Clients are not allowed to make changes to the Transfer Objects.
When the client needs the model data, and if the model is represented by a single
coarse-grained component (such as a Composite Entity), then the process of obtaining the
model data is simple. The client simply requests the coarse-grained component for its
composite Transfer Object. However, most real-world applications have a model composed
of a combination of many coarse-grained and fine-grained components. In this case, the
client must interact with numerous such business components to obtain all the data
necessary to represent the model. The immediate drawbacks of this approach can be seen in
that the clients become tightly coupled to the model implementation (model elements) and
that the clients tend to make numerous remote method invocations to obtain the data from
each individual component.
In some cases, a single coarse-grained component provides the model or parts of the
model as a single Transfer Object (simple or composite). However, when multiple
components represent the model, a single Transfer Object (simple or composite) may not
represent the entire model. To represent the model, it is necessary to obtain Transfer Objects
from various components and assemble them into a new composite Transfer Object. The
server, not the client, should perform such "on-the-fly" construction of the model.
- 浏览: 15380 次
- 性别:
- 来自: 北京
文章分类
最新评论
发表评论
-
集成层模式:Service Activator—服务激发器模式
2014-04-09 20:31 1107ContextEnterprise beans and o ... -
集成层模式:Data Access Object—数据访问对象模式
2014-04-09 20:31 533ContextAccess to data varies ... -
业务层模式:Service Locator—服务定位器模式
2014-04-09 20:31 1167ContextService lookup and cre ... -
表示层模式:Value List Handler—值列表处理器模式
2014-04-09 20:32 772ContextThe client requires a ... -
业务层模式:Composite Entity—复合实体模式
2014-04-08 21:38 498ContextEntity beans are not i ... -
业务层模式:Session Facade—会话门面模式
2014-04-08 21:38 424ContextEnterprise beans encap ... -
业务层模式:Transfer Object—传输对象模式
2014-04-08 21:37 435ContextApplication clients ne ... -
业务层模式:Business Delegate—业务委托模式
2014-04-08 21:37 985ContextA multi-tiered, distri ... -
表示层模式:Dispatcher View—分发者视图模式
2014-04-08 21:37 545ContextSystem controls flow o ... -
表示层模式:Service to Worker—工作者服务模式
2014-04-07 10:48 989ContextThe system controls flow ... -
表示层模式:Front Controller—前端控制器模式
2014-04-07 10:45 378ContextThe presentation-tier re ... -
表示层模式:Composite View—复合视图模式
2014-04-07 10:41 490ContextSophisticated Web page ... -
表示层模式:View Helper—视图助手模式
2014-04-07 10:37 1028ContextThe system creates pre ... -
表示层模式:Intercepting Filter—拦截过滤器模式
2014-04-07 10:29 627Context The presentati ...
相关推荐
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 状态模式:允许一个对象在其内部状态改变时改变它的行为。 - 策略模式:定义一组算法,并将每一个算法封装起来,使它们可以互相...
解释器模式(Interpreter)提供了一种方式来表示语言的语法和语义;策略模式(Strategy)定义了一系列算法,并使它们可以相互替换,使算法的变化独立于使用它的客户。 3. **创建型设计模式**:这类模式关注对象的...
第一部分 敏捷开发 第1章 敏捷联盟 第2章 极限编程概述 第3章 计划 第4章 测试 第5章 重构 第6章 一次编程实践 ...附录B UML表示法II:统计多路复用器 附录C 两上公司的讽刺小品 附录D 源代码就是设计 索引
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而不会暴露其底层表示。 - 中介者模式:定义一个中介对象来简化原本复杂的对象间交互。 - 备忘录模式:在不破坏封装性的前提下,捕获对象的内部状态,以便在...
- 迭代器模式:提供一种顺序访问聚合对象元素的方法,而又不暴露其底层表示。 - 中介者模式:定义一个中介对象来简化原本复杂的对象间交互。 - 观察者模式:定义对象间的一对多依赖关系,当一个对象的状态改变时...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 状态模式:允许对象在其内部状态改变时改变它的行为。 - 策略模式:定义一系列算法,并将每个算法封装起来,使它们可以互相替换。 ...
- 生成器模式:将复杂对象的构建与其表示分离,使得同样的构建过程可以创建不同的表示。 2. 结构型模式: - 适配器模式:允许两个不兼容的接口协同工作。 - 组合模式:将对象组合成树形结构,以表示部分-整体的...
20. **迭代器模式**:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 21. **访问者模式**:表示一个作用于某对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:用一个中介对象来封装一系列的对象交互,降低系统的耦合度。 - 备忘录模式:在不破坏封装性的前提下,捕获一个对象的...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:用一个中介对象来封装一系列的对象交互,降低系统的耦合度。 - 备忘录模式:在不破坏封装的前提下,捕获一个对象的...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:定义一个中介对象来简化原本复杂的对象间交互。 - 备忘录模式:在不破坏封装性的前提下,捕获对象的内部状态,并在...
4. 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 5. 观察者模式:定义对象间的一对多依赖关系,当一个对象的状态改变时,所有依赖于它的对象都会得到通知并被自动更新。 6. 状态模式:...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:用一个中介对象来封装一系列的对象交互,降低系统的耦合度。 - 备忘录模式:在不破坏封装性的前提下,捕获一个对象的...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 观察者模式:定义对象间的一对多依赖关系,当一个对象的状态改变时,所有依赖于它的对象都会得到通知并被自动更新。 - 备忘录模式...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 - 中介者模式:用一个中介对象协调各对象之间的交互。 - 备忘录模式:在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象...
- 迭代器模式:提供一种方法顺序访问聚合对象的元素,而不暴露其底层表示。 - 观察者模式:定义对象之间的一对多依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都会得到通知并自动更新。 - 状态模式...
4. 迭代器模式:提供一种方法顺序访问聚合对象的元素,而又不暴露其底层表示。 5. 中介者模式:定义一个中介对象来简化原本复杂的对象间交互。 6. 观察者模式:定义对象之间的一对多依赖关系,当一个对象状态改变时...
- 迭代器模式:提供一种顺序访问聚合对象元素的方法,而又不暴露其底层表示。 - 中介者模式:用一个中介对象协调各对象之间复杂的交互关系。 - 备忘录模式:在不破坏封装性的前提下,捕获一个对象的内部状态,并...