Chain-of-responsibility pattern

This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 03:03, 4 January 2003. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A software design patter chain-of-responsibility pattern is used for computer programming.

Intent: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

An example of this pattern is the $PATH environment variable on unix machines.

"Plan 9 has union directories: directories made of several directories all bound to the same name. The directories making up a union directory are ordered in a list. When the bindings are made (see bind(1)), flags specify whether a newly bound member goes at the head or the tail of the list or completely replaces the list. To look up a name in a union directory, each member directory is searched in list order until the name is found. A bind flag specifies whether file creation is allowed in a member directory: a file created in the union directory goes in the first member directory in list order that allows creation, if any. " [1]

The PowerPlant framework used (uses?) this pattern to dispatch events from the actual target (button) up to its super-'commanders' (window, application).

Credit

The first draft is based on an excerpt from WikiWikiWeb.