The Chain of Responsibility pattern is a behavioral GoF design pattern by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides that avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle it. The receiving objects form a chain, and each handler either processes the request or passes it to the next. The set of handlers can be specified dynamically, as in a middleware pipeline.
GoF-Chain of Responsibility Pattern
Details
- Full Name
-
GoF Chain of Responsibility Pattern (Behavioral)
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.
When to Use:
-
When more than one object may handle a request, and the handler isn’t known a priori
-
When you want to issue a request to one of several objects without specifying the receiver explicitly
-
When the set of objects that can handle a request should be specified dynamically
Prompt Example:
"Implementiere eine Middleware-Pipeline nach dem GoF-Chain of Responsibility Pattern, bei der jeder Handler die Anfrage entweder verarbeitet oder an den nächsten weitergibt."
Related Anchors:
-
GoF Design Patterns (Umbrella)