Difference between revisions of "Chain-of-responsibility pattern"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In object-oriented design, the '''chain-of-responsibility pattern''' is a design pattern consisting of a source of command objects and a series of...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
In [[object-oriented design]], the '''chain-of-responsibility pattern''' is a [[design pattern]] consisting of a source of [[Command pattern|command objects]] and a series of processing objects.
+
In [[object-oriented programming]], the '''chain-of-responsibility pattern''' is a [[software design pattern]] consisting of a source of [[Command pattern|command objects]] and a series of processing objects.
  
 
== Description ==
 
== Description ==
Line 9: Line 9:
 
In some cases, this can occur recursively, with processing objects calling higher-up processing objects with commands that attempt to solve some smaller part of the problem; in this case recursion continues until the command is processed, or the entire tree has been explored. An XML interpreter might work in this manner.
 
In some cases, this can occur recursively, with processing objects calling higher-up processing objects with commands that attempt to solve some smaller part of the problem; in this case recursion continues until the command is processed, or the entire tree has been explored. An XML interpreter might work in this manner.
  
This pattern promotes the idea of loose coupling.
+
This pattern promotes the idea of [[loose coupling]].
  
 
== See also ==
 
== See also ==
  
 
* [[Command pattern]]
 
* [[Command pattern]]
 +
* [[Loose coupling]]
 +
* [[Object-oriented programming]]
 
* [[Software design pattern]]
 
* [[Software design pattern]]
 
* [[Software engineering]]
 
* [[Software engineering]]
Line 23: Line 25:
  
 
[[Category:Computer science]]
 
[[Category:Computer science]]
 +
[[Category:Software design patterns]]
 
[[Category:Software engineering]]
 
[[Category:Software engineering]]

Latest revision as of 20:52, 3 September 2016

In object-oriented programming, the chain-of-responsibility pattern is a software design pattern consisting of a source of command objects and a series of processing objects.

Description

Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain.

In a variation of the standard chain-of-responsibility model, some handlers may act as dispatchers, capable of sending commands out in a variety of directions, forming a tree of responsibility.

In some cases, this can occur recursively, with processing objects calling higher-up processing objects with commands that attempt to solve some smaller part of the problem; in this case recursion continues until the command is processed, or the entire tree has been explored. An XML interpreter might work in this manner.

This pattern promotes the idea of loose coupling.

See also

External links