{"id":"6b08bd3080884893657cc8fc","slug":"chain-of-responsibility","title":"Chain of Responsibility: pass it on until someone takes care of it","summary":"The Chain of Responsibility pattern through complaints in a pierogi place: a bot, a shift manager and the owner form a chain, and a complaint travels until it reaches someone authorised. The classic variant and the middleware pipeline, code in five languages.","servedLang":"en","availableLangs":["pl","en"],"topics":["chain-of-responsibility"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","chain-of-responsibility","middleware","pipeline"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":13,"stats":{"views":3,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:52.282Z","updatedAt":"2026-11-27T13:20:51.150Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"violet","background":"dots","weaveResources":true,"toc":"right"},"seoDescription":"The Chain of Responsibility design pattern in C#, TypeScript, Java, Go and Python: handlers, passing requests on, middleware in ASP.NET Core and Express.","wordCount":2447,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"A customer writes that the pierogi arrived cold. If it is about 15 PLN and there is a photo, a bot can issue the refund. For a larger amount the shift manager decides, and for a really big one – Halina herself. "},{"type":"text","text":"Chain of Responsibility","marks":[{"type":"bold"}]},{"type":"text","text":" lines such handlers up: a request travels from one to the next until someone takes it over."}]},{"type":"callout","attrs":{"variant":"tip","title":"In short"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Handlers form a "},{"type":"text","text":"chain","marks":[{"type":"bold"}]},{"type":"text","text":"; each one only knows the next."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Each link "},{"type":"text","text":"decides on its own","marks":[{"type":"bold"}]},{"type":"text","text":": handle the request or pass it on."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The sender does not know who will eventually handle the request – it only knows the start of the chain."}]}]}]}]},{"type":"stats","attrs":{"items":[{"value":"3","label":"links in the chain","hint":"bot, shift manager, owner"},{"value":"20 PLN","label":"automatic refund limit","hint":"with a photo"},{"value":"1","label":"entry point for the sender","hint":"the first link"}]}},{"type":"heading","attrs":{"level":2,"id":"the-problem-one-function-knows-the-whole-hierarchy"},"content":[{"type":"text","text":"The problem: one function knows the whole hierarchy"}]},{"type":"paragraph","content":[{"type":"text","text":"Complaint handling started with an ordinary "},{"type":"text","text":"if","marks":[{"type":"code"}]},{"type":"text","text":"/"},{"type":"text","text":"elif","marks":[{"type":"code"}]},{"type":"text","text":":"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"complaints_before.py"},"content":[{"type":"text","text":"def handle_complaint(c: Complaint) -> str:\n    if c.amount <= 20 and c.has_photo:\n        return refund_automatically(c)\n    elif c.amount <= 100 and is_shift_manager_on_duty():\n        return ask_shift_manager(c)\n    elif c.amount <= 100:\n        return ask_owner(c)  # copy of the branch below, \"temporarily\"\n    else:\n        return ask_owner(c)\n    # next request: \"add an AI triage step before the bot, but only on weekends\""}]},{"type":"paragraph","content":[{"type":"text","text":"The function knows all the participants of the process, their limits and their order. Every change – a new verification step, a different threshold, triage by an AI model at weekends – means editing the same function. Nor can you assemble a different chain for a different channel (complaints from the delivery app skip the bot, say) without copying the whole thing."}]},{"type":"heading","attrs":{"level":2,"id":"the-solution-handlers-linked-into-a-chain"},"content":[{"type":"text","text":"The solution: handlers linked into a chain"}]},{"type":"paragraph","content":[{"type":"text","text":"Every participant of the process becomes an object with a "},{"type":"text","text":"handle(complaint)","marks":[{"type":"code"}]},{"type":"text","text":" method and a reference to the "},{"type":"text","text":"next","marks":[{"type":"bold"}]},{"type":"text","text":" link. A link checks whether it can handle the request; if so, it handles it and stops; if not, it passes it on. The order and composition of the chain are set by configuration code, not by the handlers themselves."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  R([\"Complaint\"]) --> B{\"Bot: ≤ 20 PLN and a photo?\"}\n  B -- yes --> B1[\"Automatic refund\"]\n  B -- no --> M{\"Manager: ≤ 100 PLN?\"}\n  M -- yes --> M1[\"Manager's approval\"]\n  M -- no --> O[\"Halina: calls the customer\"]","caption":"The complaint handling chain"}},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  participant C as Customer\n  participant B as AutoRefund\n  participant M as ShiftManager\n  participant O as Owner\n  C->>B: handle(order 103, 340 PLN)\n  Note over B: above the limit – pass it on\n  B->>M: handle(...)\n  Note over M: above the limit – pass it on\n  M->>O: handle(...)\n  O-->>M: Halina will call the customer\n  M-->>B: result\n  B-->>C: result","caption":"A 340 PLN complaint travels through the whole chain"}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Role"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"In the example"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Responsibility"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Handler"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"ComplaintHandler","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the common interface and a reference to the next link"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Concrete handler"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"AutoRefund","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"ShiftManager","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Owner","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"decides: handle or pass on"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Client"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the complaint form"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"sends the request to the first link"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Configuration"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the code building the chain"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"sets the composition and order of links"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"implementation-in-five-languages"},"content":[{"type":"text","text":"Implementation in five languages"}]},{"type":"paragraph","content":[{"type":"text","text":"In C#, TypeScript, Java and Python the base class holds a reference to the next link and implements the \"handle or pass on\" logic, while subclasses only provide the condition and the way to handle it. "},{"type":"text","text":"setNext","marks":[{"type":"code"}]},{"type":"text","text":" returns the next link, so the chain is built fluently. In Go a link is a struct with two functions, and the "},{"type":"text","text":"Chain","marks":[{"type":"code"}]},{"type":"text","text":" function assembles the chain."}]},{"type":"codeGroup","attrs":{"title":"Chain of Responsibility – complaints"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"Complaints.cs"},"content":[{"type":"text","text":"var chain = new AutoRefund();\nchain.SetNext(new ShiftManager()).SetNext(new Owner());\n\nConsole.WriteLine(chain.Handle(new Complaint(101, 15m, HasPhoto: true)));  // Bot: refunded 15 PLN\nConsole.WriteLine(chain.Handle(new Complaint(102, 15m, HasPhoto: false))); // Shift manager approved 15 PLN\nConsole.WriteLine(chain.Handle(new Complaint(103, 340m, HasPhoto: true))); // Halina will call the customer\n\npublic sealed record Complaint(int OrderId, decimal Amount, bool HasPhoto);\n\npublic abstract class ComplaintHandler\n{\n    private ComplaintHandler? _next;\n\n    // Returns the next handler, so the chain can be built fluently.\n    public ComplaintHandler SetNext(ComplaintHandler next) => _next = next;\n\n    public string Handle(Complaint c) =>\n        CanHandle(c) ? Resolve(c)\n        : _next?.Handle(c) ?? $\"#{c.OrderId}: nobody could handle the complaint\";\n\n    protected abstract bool CanHandle(Complaint c);\n    protected abstract string Resolve(Complaint c);\n}\n\npublic sealed class AutoRefund : ComplaintHandler\n{\n    protected override bool CanHandle(Complaint c) => c.Amount <= 20m && c.HasPhoto;\n    protected override string Resolve(Complaint c) => $\"#{c.OrderId}: Bot: refunded {c.Amount} PLN\";\n}\n\npublic sealed class ShiftManager : ComplaintHandler\n{\n    protected override bool CanHandle(Complaint c) => c.Amount <= 100m;\n    protected override string Resolve(Complaint c) => $\"#{c.OrderId}: Shift manager approved {c.Amount} PLN\";\n}\n\npublic sealed class Owner : ComplaintHandler\n{\n    protected override bool CanHandle(Complaint c) => true; // the last link takes everything\n    protected override string Resolve(Complaint c) => $\"#{c.OrderId}: Halina will call the customer\";\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"complaints.ts"},"content":[{"type":"text","text":"type Complaint = { orderId: number; amount: number; hasPhoto: boolean };\n\nabstract class ComplaintHandler {\n  private next?: ComplaintHandler;\n\n  /** Returns the next handler, so the chain can be built fluently. */\n  setNext(next: ComplaintHandler): ComplaintHandler {\n    this.next = next;\n    return next;\n  }\n\n  handle(c: Complaint): string {\n    if (this.canHandle(c)) return this.resolve(c);\n    return this.next?.handle(c) ?? `#${c.orderId}: nobody could handle the complaint`;\n  }\n\n  protected abstract canHandle(c: Complaint): boolean;\n  protected abstract resolve(c: Complaint): string;\n}\n\nclass AutoRefund extends ComplaintHandler {\n  protected canHandle(c: Complaint) { return c.amount <= 20 && c.hasPhoto; }\n  protected resolve(c: Complaint) { return `#${c.orderId}: Bot: refunded ${c.amount} PLN`; }\n}\n\nclass ShiftManager extends ComplaintHandler {\n  protected canHandle(c: Complaint) { return c.amount <= 100; }\n  protected resolve(c: Complaint) { return `#${c.orderId}: Shift manager approved ${c.amount} PLN`; }\n}\n\nclass Owner extends ComplaintHandler {\n  protected canHandle() { return true; } // the last link takes everything\n  protected resolve(c: Complaint) { return `#${c.orderId}: Halina will call the customer`; }\n}\n\nconst chain = new AutoRefund();\nchain.setNext(new ShiftManager()).setNext(new Owner());\n\nconsole.log(chain.handle({ orderId: 101, amount: 15, hasPhoto: true }));  // Bot: refunded 15 PLN\nconsole.log(chain.handle({ orderId: 102, amount: 15, hasPhoto: false })); // Shift manager approved 15 PLN\nconsole.log(chain.handle({ orderId: 103, amount: 340, hasPhoto: true })); // Halina will call the customer"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"Complaints.java"},"content":[{"type":"text","text":"record Complaint(int orderId, double amount, boolean hasPhoto) {}\n\nabstract class ComplaintHandler {\n    private ComplaintHandler next;\n\n    // Returns the next handler, so the chain can be built fluently.\n    ComplaintHandler setNext(ComplaintHandler next) {\n        this.next = next;\n        return next;\n    }\n\n    final String handle(Complaint c) {\n        if (canHandle(c)) return resolve(c);\n        return next != null ? next.handle(c) : \"#\" + c.orderId() + \": nobody could handle the complaint\";\n    }\n\n    protected abstract boolean canHandle(Complaint c);\n    protected abstract String resolve(Complaint c);\n}\n\nclass AutoRefund extends ComplaintHandler {\n    protected boolean canHandle(Complaint c) { return c.amount() <= 20 && c.hasPhoto(); }\n    protected String resolve(Complaint c) { return \"#%d: Bot: refunded %.0f PLN\".formatted(c.orderId(), c.amount()); }\n}\n\nclass ShiftManager extends ComplaintHandler {\n    protected boolean canHandle(Complaint c) { return c.amount() <= 100; }\n    protected String resolve(Complaint c) { return \"#%d: Shift manager approved %.0f PLN\".formatted(c.orderId(), c.amount()); }\n}\n\nclass Owner extends ComplaintHandler {\n    protected boolean canHandle(Complaint c) { return true; } // the last link takes everything\n    protected String resolve(Complaint c) { return \"#%d: Halina will call the customer\".formatted(c.orderId()); }\n}\n\npublic class Complaints {\n    public static void main(String[] args) {\n        var chain = new AutoRefund();\n        chain.setNext(new ShiftManager()).setNext(new Owner());\n\n        System.out.println(chain.handle(new Complaint(101, 15, true)));  // Bot: refunded 15 PLN\n        System.out.println(chain.handle(new Complaint(102, 15, false))); // Shift manager approved 15 PLN\n        System.out.println(chain.handle(new Complaint(103, 340, true))); // Halina will call the customer\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"complaints.go"},"content":[{"type":"text","text":"package main\n\nimport \"fmt\"\n\ntype Complaint struct {\n\tOrderID  int\n\tAmount   float64\n\tHasPhoto bool\n}\n\ntype Handler interface {\n\tHandle(c Complaint) string\n}\n\n// link is one handler in the chain: it resolves the complaint or passes it on.\ntype link struct {\n\tname    string\n\tcan     func(Complaint) bool\n\tresolve func(Complaint) string\n\tnext    Handler\n}\n\nfunc (l *link) Handle(c Complaint) string {\n\tif l.can(c) {\n\t\treturn fmt.Sprintf(\"#%d: %s: %s\", c.OrderID, l.name, l.resolve(c))\n\t}\n\tif l.next == nil {\n\t\treturn fmt.Sprintf(\"#%d: nobody could handle the complaint\", c.OrderID)\n\t}\n\treturn l.next.Handle(c)\n}\n\n// Chain links the handlers in order and returns the first one.\nfunc Chain(links ...*link) Handler {\n\tfor i := 0; i < len(links)-1; i++ {\n\t\tlinks[i].next = links[i+1]\n\t}\n\treturn links[0]\n}\n\nfunc main() {\n\tchain := Chain(\n\t\t&link{name: \"Bot\",\n\t\t\tcan:     func(c Complaint) bool { return c.Amount <= 20 && c.HasPhoto },\n\t\t\tresolve: func(c Complaint) string { return fmt.Sprintf(\"refunded %.0f PLN\", c.Amount) }},\n\t\t&link{name: \"Shift manager\",\n\t\t\tcan:     func(c Complaint) bool { return c.Amount <= 100 },\n\t\t\tresolve: func(c Complaint) string { return fmt.Sprintf(\"approved %.0f PLN\", c.Amount) }},\n\t\t&link{name: \"Owner\",\n\t\t\tcan:     func(Complaint) bool { return true }, // the last link takes everything\n\t\t\tresolve: func(Complaint) string { return \"Halina will call the customer\" }},\n\t)\n\tfmt.Println(chain.Handle(Complaint{101, 15, true}))\n\tfmt.Println(chain.Handle(Complaint{102, 15, false}))\n\tfmt.Println(chain.Handle(Complaint{103, 340, true}))\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"complaints.py"},"content":[{"type":"text","text":"from __future__ import annotations\n\nfrom abc import ABC, abstractmethod\nfrom dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass Complaint:\n    order_id: int\n    amount: float\n    has_photo: bool\n\n\nclass ComplaintHandler(ABC):\n    def __init__(self) -> None:\n        self._next: ComplaintHandler | None = None\n\n    def set_next(self, handler: ComplaintHandler) -> ComplaintHandler:\n        \"\"\"Returns the next handler, so the chain can be built fluently.\"\"\"\n        self._next = handler\n        return handler\n\n    def handle(self, c: Complaint) -> str:\n        if self.can_handle(c):\n            return self.resolve(c)\n        if self._next is None:\n            return f\"#{c.order_id}: nobody could handle the complaint\"\n        return self._next.handle(c)\n\n    @abstractmethod\n    def can_handle(self, c: Complaint) -> bool: ...\n\n    @abstractmethod\n    def resolve(self, c: Complaint) -> str: ...\n\n\nclass AutoRefund(ComplaintHandler):\n    def can_handle(self, c): return c.amount <= 20 and c.has_photo\n    def resolve(self, c): return f\"#{c.order_id}: Bot: refunded {c.amount:.0f} PLN\"\n\n\nclass ShiftManager(ComplaintHandler):\n    def can_handle(self, c): return c.amount <= 100\n    def resolve(self, c): return f\"#{c.order_id}: Shift manager approved {c.amount:.0f} PLN\"\n\n\nclass Owner(ComplaintHandler):\n    def can_handle(self, c): return True  # the last link takes everything\n    def resolve(self, c): return f\"#{c.order_id}: Halina will call the customer\"\n\n\nchain = AutoRefund()\nchain.set_next(ShiftManager()).set_next(Owner())\nfor complaint in (Complaint(101, 15, True), Complaint(102, 15, False), Complaint(103, 340, True)):\n    print(chain.handle(complaint))"}]}]}]},"toc":[{"id":"the-problem-one-function-knows-the-whole-hierarchy","text":"The problem: one function knows the whole hierarchy","level":2,"locked":false},{"id":"the-solution-handlers-linked-into-a-chain","text":"The solution: handlers linked into a chain","level":2,"locked":false},{"id":"implementation-in-five-languages","text":"Implementation in five languages","level":2,"locked":false},{"id":"step-by-step","text":"Step by step","level":2,"locked":true},{"id":"different-chains-from-the-same-links","text":"Different chains from the same links","level":2,"locked":true},{"id":"a-variant-the-middleware-pipeline","text":"A variant: the middleware pipeline","level":2,"locked":true},{"id":"when-to-use-it-and-when-not-to","text":"When to use it and when not to","level":2,"locked":true},{"id":"related-patterns","text":"Related patterns","level":2,"locked":true},{"id":"in-practice","text":"In practice","level":2,"locked":true},{"id":"test-yourself","text":"Test yourself","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":39,"visibleBlocks":15,"resources":[{"id":"6b0857bf3c96f2d34d0b427b","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/chain-of-responsibility","embedUrl":null,"title":"Łańcuch zobowiązań / Chain of Responsibility","description":"Łańcuch zobowiązań jest behawioralnym wzorcem projektowym, który pozwala przekazywać żądania wzdłuż łańcucha obiektów obsługujących. Otrzymawszy żądanie, każdy z obiektów obsługujących decyduje o przetworzeniu żądania lub przekazaniu go do kolejnego obiektu obsługującego w łańcuchu.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["chain-of-responsibility"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:11.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857c73c96f2d34d0b4969","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=msXtN15qXOE","embedUrl":"https://www.youtube-nocookie.com/embed/msXtN15qXOE","title":"Building a Request Pipeline for Separating Concerns with Pipes & Filters","description":"How do you separate concerns when processing a request? Typical concerns such as Logging, Validation, Exception Handling, Retries, and many more. One way is to build a request pipeline for separating concerns by using the Pipes and Filters pattern. You can also build a pipeline using the Russian…","author":"CodeOpinion","thumbnailUrl":"https://i.ytimg.com/vi/msXtN15qXOE/hqdefault.jpg","durationSec":null,"lang":"en","topics":["event-sourcing"],"techs":["dotnet"],"tags":["software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2021-08-18T14:00:17.000Z","popularity":63,"verifiedAt":"2026-11-26T10:53:51.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857bc3c96f2d34d0b4047","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/design-patterns-iterators-observers-and-chains-oh-my/id769189585?i=1000378375263","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id769189585?i=1000378375263","title":"Design Patterns – Iterators, Observers, and Chains, Oh My","description":"We’re back to the gang of four, continuing with another segment of design patterns. This time we’re talking about some of our favorite Behavioral Design Patterns: Observer, Chain of Responsibilities, Iterator patterns. Also, why the visitor pattern is weird and what it’s like to be raked over hot…","author":"Coding Blocks","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/f0/b6/68/f0b6682f-e8bc-181c-95a9-0756ddf63d6e/mza_3128980961332034780.jpg/600x600bb.jpg","durationSec":3828,"lang":"en","topics":["iterator","visitor"],"techs":["general"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2014-11-09T01:53:47.000Z","popularity":44,"verifiedAt":"2026-11-26T10:57:23.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857c33c96f2d34d0b4658","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL6030812W","embedUrl":null,"title":"Design Patterns: Elements of Reusable Object-Oriented Software","description":"","author":"Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson","thumbnailUrl":"https://covers.openlibrary.org/b/id/6601119-L.jpg","durationSec":null,"lang":"en","topics":["factory-method","abstract-factory","builder","prototype","singleton","adapter","bridge","composite","decorator","facade","flyweight","proxy","chain-of-responsibility","command","iterator","mediator","memento","observer","state","strategy","template-method","visitor"],"techs":["general"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"1995-01-01T00:00:00.000Z","popularity":71,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"}],"challenges":[{"id":"6b093dc191bd8fbaf2a0c8c4","slug":"expense-approval-chain","title":"Expense approval chain","summary":"An expense travels through links – receipt check, team lead, manager, director – until someone approves or rejects it. Chain of Responsibility with pluggable links.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"easy","topics":["chain-of-responsibility"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["chain-of-responsibility","approval-workflow","behavioral","middleware"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:25.083Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"gof-behavioral","title":"GoF behavioral patterns","items":[{"slug":"strategy","title":"Strategy: interchangeable algorithms instead of an if-else ladder","current":false},{"slug":"observer","title":"Observer: notify everyone without knowing anyone","current":false},{"slug":"command","title":"Command: a request wrapped in an object","current":false},{"slug":"state","title":"State: an object that changes behaviour with its life stage","current":false},{"slug":"template-method","title":"Template Method: a fixed recipe, interchangeable ingredients","current":false},{"slug":"iterator","title":"Iterator: walking a collection without looking inside","current":false},{"slug":"chain-of-responsibility","title":"Chain of Responsibility: pass it on until someone takes care of it","current":true},{"slug":"mediator","title":"Mediator: components talk through a coordinator","current":false},{"slug":"memento","title":"Memento: a state snapshot without breaking encapsulation","current":false},{"slug":"visitor","title":"Visitor: new operations without changing classes","current":false}]}],"prev":{"slug":"iterator","title":"Iterator: walking a collection without looking inside"},"next":{"slug":"mediator","title":"Mediator: components talk through a coordinator"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":68,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":63},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":53},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":52},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":38}]}}