Java Reference
In-Depth Information
Chain of Responsibility without Composite
C HAIN OF R ESPONSIBILITY requires a strategy for ordering the search for an object that can
handle a request. Usually, the order to follow will depend on an underlying aspect in
the modeled domain. This frequently occurs when there is composition, as in the Oozinoz
machine hierarchy. However, this pattern can apply outside object models that are
composites.
CHALLENGE 12.5
Cite an example when the C HAIN OF R ESPONSIBILITY pattern might occur if
the chained objects do not form a composite.
Summary
When you apply the C HAIN OF R ESPONSIBILITY pattern, you relieve a client from having to
know which object in a collection supports a given behavior. By setting up the search for
responsibility to occur across objects, you decouple the client from any specific object in the
chain.
The C HAIN OF R ESPONSIBILITY pattern occurs occasionally when an arbitrary chain of
objects can apply a series of different strategies to tackling a problem, such as parsing a user's
input. More frequently this pattern occurs in aggregations, in which a containment hierarchy
provides a natural ordering for a chain of objects.C HAIN OF R ESPONSIBILITY leads to simpler
code in both the hierarchy and the client, which is the main advantage of this pattern.
Search WWH ::




Custom Search