Digging further, there are included at least two meanings here.
First, there are objects that have a common responsibility, which means these
objects can be abstracted into a common interface. Secondly, it is the meaning
of the "chain." The so-called "chain" from the angle of
data structure, corresponds to the chain typed persisting structure, one of
whose outstanding characteristics is that the factual elements are close
together in the logical structure, while in the physical position not
necessarily the case. Therefore, it is unlike an array that can be accessed at
random. In the meantime, once any element in the chain becomes disjointed, the message
delivered in the chain will be interrupted. Therefore, it will be a more
comfortable way to provide a special class or method to carry out the responsibility
of taking care of this chain of responsibility.
As you know, the ultimate purpose to introduce the Chain of
Responsibility pattern is to achieve the aim of decoupling. And, from the angle
of "encapsulate what varies," it seals the variety of responsibility behavior,
in the meantime again, makes use of a chain structure to insure the deliver of
news. All in all, the biggest advantage to introduce the Chain of
Responsibility pattern lies in it can intelligently locate the suitable object in
the responsibility chain according to specified conditions incumbency, and then
the found object can carry out its responsibility.
In this article, I will show you the typical utilization of
the Chain of Responsibility design pattern by building up a simple service
explorer application with gradual modifications.