{"id":"6b08bd2f80884893657cc8e8","slug":"bridge","title":"Bridge – two axes of change without a class explosion","summary":"Bridge separates the abstraction (what we do) from the implementation (how we do it), so both hierarchies can evolve independently. An example of notifications and delivery channels in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["bridge","adapter","strategy","abstract-factory"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","bridge","composition-over-inheritance"],"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":11,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:51.587Z","updatedAt":"2026-11-27T13:05:36.191Z","requestedLang":"en","theme":{"hero":"minimal","heroMedia":null,"accent":"indigo","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"The Bridge design pattern – the problem of multiplying classes across two dimensions of change, abstraction and implementor, a UML diagram, a class count chart, code in C#, TypeScript, Java, Go and Python, examples of HttpClient, slog and JDBC.","wordCount":2167,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Bridge sounds like the most abstract pattern in the whole catalog, yet it solves a very down-to-earth problem: a class hierarchy that grows in two directions at once. "},{"type":"text","text":"Bridge","marks":[{"type":"bold"}]},{"type":"text","text":" splits it into two independent hierarchies connected by a reference – the \"bridge\" – instead of inheritance."}]},{"type":"callout","attrs":{"variant":"info","title":"In short"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The abstraction ("},{"type":"text","text":"what","marks":[{"type":"italic"}]},{"type":"text","text":" we do: an alert, a reminder) holds a reference to the implementor ("},{"type":"text","text":"how","marks":[{"type":"italic"}]},{"type":"text","text":": email, SMS, push)."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Both hierarchies grow separately: a new channel needs no new notice classes and vice versa."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Instead of n × m subclasses you have n + m classes."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-emailurgentalert-smsurgentalert-pushurgentalert"},"content":[{"type":"text","text":"The problem: EmailUrgentAlert, SmsUrgentAlert, PushUrgentAlert…"}]},{"type":"paragraph","content":[{"type":"text","text":"The pierogi place sends notifications to customers. There are "},{"type":"text","text":"urgent alerts","marks":[{"type":"bold"}]},{"type":"text","text":" (a failed payment) and "},{"type":"text","text":"reminders","marks":[{"type":"bold"}]},{"type":"text","text":" (your order arrives in 30 minutes). Each can go by email or SMS. The first design was based on inheritance:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"notifications.ts"},"content":[{"type":"text","text":"class EmailAlert extends EmailSender { /* urgent formatting + email */ }\nclass SmsAlert extends SmsSender { /* urgent formatting again + SMS */ }\nclass EmailReminder extends EmailSender { /* reminder formatting + email */ }\nclass SmsReminder extends SmsSender { /* reminder formatting again + SMS */ }\n// next sprint: PushAlert, PushReminder… and a third kind of notice"}]},{"type":"paragraph","content":[{"type":"text","text":"Four classes is nothing yet. But marketing wants push notifications and a messenger, and product wants a third kind of message (a daily summary). Alert formatting is copied into every \"…Alert\" class, and the 160-character limit into every \"Sms…\" one. Every change along one dimension means editing many classes."}]},{"type":"chart","attrs":{"type":"line","title":"Number of classes with 4 kinds of notices","caption":"Inheritance: kinds × channels. Bridge: kinds + channels. Computed values, not measurements.","unit":"classes","data":{"labels":["1 channel","2 channels","3 channels","4 channels","5 channels","6 channels"],"series":[{"name":"Inheritance","values":[4,8,12,16,20,24]},{"name":"Bridge","values":[5,6,7,8,9,10]}]}}},{"type":"heading","attrs":{"level":2,"id":"the-solution-two-hierarchies-and-a-reference-between-them"},"content":[{"type":"text","text":"The solution: two hierarchies and a reference between them"}]},{"type":"paragraph","content":[{"type":"text","text":"We recognise two independent dimensions. The "},{"type":"text","text":"abstraction","marks":[{"type":"bold"}]},{"type":"text","text":" answers "},{"type":"text","text":"what we communicate","marks":[{"type":"italic"}]},{"type":"text","text":": "},{"type":"text","text":"Notice","marks":[{"type":"code"}]},{"type":"text","text":" with the "},{"type":"text","text":"Alert","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":"Reminder","marks":[{"type":"code"}]},{"type":"text","text":" subclasses – this is where the formatting and logic of each kind of message live. The "},{"type":"text","text":"implementor","marks":[{"type":"bold"}]},{"type":"text","text":" answers "},{"type":"text","text":"how we deliver it","marks":[{"type":"italic"}]},{"type":"text","text":": a "},{"type":"text","text":"Channel","marks":[{"type":"code"}]},{"type":"text","text":" interface with "},{"type":"text","text":"EmailChannel","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":"SmsChannel","marks":[{"type":"code"}]},{"type":"text","text":" implementations – this is where transport details live, such as the SMS length limit. The abstraction receives a channel in its constructor and delegates delivery to it."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"classDiagram\n  direction LR\n  class Notice {\n    <<abstract>>\n    #channel Channel\n    +notify(recipient, text)*\n  }\n  class Alert {\n    +notify(recipient, text)\n  }\n  class Reminder {\n    -lead\n    +notify(recipient, text)\n  }\n  class Channel {\n    <<interface>>\n    +deliver(recipient, title, body)\n  }\n  Notice <|-- Alert\n  Notice <|-- Reminder\n  Notice o-- Channel : bridge\n  Channel <|.. EmailChannel\n  Channel <|.. SmsChannel\n  Channel <|.. PushChannel","caption":"Bridge: the abstraction and the implementor grow independently"}},{"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":"Abstraction"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Notice","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the high-level interface for the client; holds the implementor"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Refined abstraction"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Alert","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Reminder","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"variants of the \"what\" logic"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Implementor"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Channel","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"primitive operations the abstraction relies on"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Concrete implementor"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"EmailChannel","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"SmsChannel","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"variants of the \"how\" – concrete platforms, protocols, libraries"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"An important difference from plain dependency injection: the implementor's interface is usually "},{"type":"text","text":"lower-level","marks":[{"type":"bold"}]},{"type":"text","text":" than the abstraction's. A channel only knows \"deliver a title and body to a recipient\"; it is the abstraction that knows an alert is written in capitals and a reminder includes the time until delivery."}]},{"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 class-based languages the abstraction is an abstract class with a "},{"type":"text","text":"channel","marks":[{"type":"code"}]},{"type":"text","text":" field. In Go, instead of a hierarchy there are two structs with a field of type "},{"type":"text","text":"Channel","marks":[{"type":"code"}]},{"type":"text","text":" – the bridge is simply an interface-typed field, and inheritance is not needed at all."}]},{"type":"codeGroup","attrs":{"title":"Notice + Channel"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"Notifications.cs"},"content":[{"type":"text","text":"new Alert(new SmsChannel()).Notify(\"Ola\", \"Payment for order 1042 failed\");\nnew Reminder(new EmailChannel(), TimeSpan.FromMinutes(30)).Notify(\"Ola\", \"Your pierogi arrive soon\");\n\n// Implementor: how a message travels.\npublic interface IChannel\n{\n    void Deliver(string recipient, string title, string body);\n}\n\npublic sealed class EmailChannel : IChannel\n{\n    public void Deliver(string recipient, string title, string body) =>\n        Console.WriteLine($\"[email to {recipient}] Subject: {title} | {body}\");\n}\n\npublic sealed class SmsChannel : IChannel\n{\n    // SMS has no subject line and a hard length limit.\n    public void Deliver(string recipient, string title, string body)\n    {\n        var text = $\"{title}: {body}\";\n        Console.WriteLine($\"[sms to {recipient}] {(text.Length > 160 ? text[..157] + \"...\" : text)}\");\n    }\n}\n\n// Abstraction: what the message means. It holds a channel instead of inheriting one.\npublic abstract class Notice(IChannel channel)\n{\n    protected IChannel Channel { get; } = channel;\n\n    public abstract void Notify(string recipient, string text);\n}\n\npublic sealed class Alert(IChannel channel) : Notice(channel)\n{\n    public override void Notify(string recipient, string text) =>\n        Channel.Deliver(recipient, \"URGENT\", text.ToUpperInvariant());\n}\n\npublic sealed class Reminder(IChannel channel, TimeSpan lead) : Notice(channel)\n{\n    public override void Notify(string recipient, string text) =>\n        Channel.Deliver(recipient, $\"Reminder, {lead.TotalMinutes:0} min left\", text);\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"notifications.ts"},"content":[{"type":"text","text":"// Implementor: how a message travels.\ninterface Channel {\n  deliver(recipient: string, title: string, body: string): void;\n}\n\nclass EmailChannel implements Channel {\n  deliver(recipient: string, title: string, body: string): void {\n    console.log(`[email to ${recipient}] Subject: ${title} | ${body}`);\n  }\n}\n\nclass SmsChannel implements Channel {\n  // SMS has no subject line and a hard length limit.\n  deliver(recipient: string, title: string, body: string): void {\n    const text = `${title}: ${body}`;\n    console.log(`[sms to ${recipient}] ${text.length > 160 ? text.slice(0, 157) + \"...\" : text}`);\n  }\n}\n\n// Abstraction: what the message means. It holds a channel instead of inheriting one.\nabstract class Notice {\n  constructor(protected readonly channel: Channel) {}\n  abstract notify(recipient: string, text: string): void;\n}\n\nclass Alert extends Notice {\n  notify(recipient: string, text: string): void {\n    this.channel.deliver(recipient, \"URGENT\", text.toUpperCase());\n  }\n}\n\nclass Reminder extends Notice {\n  constructor(channel: Channel, private readonly leadMinutes: number) {\n    super(channel);\n  }\n\n  notify(recipient: string, text: string): void {\n    this.channel.deliver(recipient, `Reminder, ${this.leadMinutes} min left`, text);\n  }\n}\n\nnew Alert(new SmsChannel()).notify(\"Ola\", \"Payment for order 1042 failed\");\nnew Reminder(new EmailChannel(), 30).notify(\"Ola\", \"Your pierogi arrive soon\");"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"Notifications.java"},"content":[{"type":"text","text":"import java.time.Duration;\n\n// Implementor: how a message travels.\ninterface Channel {\n    void deliver(String recipient, String title, String body);\n}\n\nclass EmailChannel implements Channel {\n    public void deliver(String recipient, String title, String body) {\n        System.out.printf(\"[email to %s] Subject: %s | %s%n\", recipient, title, body);\n    }\n}\n\nclass SmsChannel implements Channel {\n    // SMS has no subject line and a hard length limit.\n    public void deliver(String recipient, String title, String body) {\n        String text = title + \": \" + body;\n        System.out.printf(\"[sms to %s] %s%n\", recipient, text.length() > 160 ? text.substring(0, 157) + \"...\" : text);\n    }\n}\n\n// Abstraction: what the message means. It holds a channel instead of inheriting one.\nabstract class Notice {\n    protected final Channel channel;\n    protected Notice(Channel channel) { this.channel = channel; }\n    abstract void notify(String recipient, String text);\n}\n\nclass Alert extends Notice {\n    Alert(Channel channel) { super(channel); }\n    void notify(String recipient, String text) { channel.deliver(recipient, \"URGENT\", text.toUpperCase()); }\n}\n\nclass Reminder extends Notice {\n    private final Duration lead;\n    Reminder(Channel channel, Duration lead) { super(channel); this.lead = lead; }\n    void notify(String recipient, String text) {\n        channel.deliver(recipient, \"Reminder, \" + lead.toMinutes() + \" min left\", text);\n    }\n}\n\npublic class Notifications {\n    public static void main(String[] args) {\n        new Alert(new SmsChannel()).notify(\"Ola\", \"Payment for order 1042 failed\");\n        new Reminder(new EmailChannel(), Duration.ofMinutes(30)).notify(\"Ola\", \"Your pierogi arrive soon\");\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"notifications.go"},"content":[{"type":"text","text":"package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n)\n\n// Channel is the implementor: how a message travels.\ntype Channel interface {\n\tDeliver(recipient, title, body string)\n}\n\ntype EmailChannel struct{}\n\nfunc (EmailChannel) Deliver(recipient, title, body string) {\n\tfmt.Printf(\"[email to %s] Subject: %s | %s\\n\", recipient, title, body)\n}\n\n// SmsChannel has no subject line and a hard length limit.\ntype SmsChannel struct{}\n\nfunc (SmsChannel) Deliver(recipient, title, body string) {\n\ttext := title + \": \" + body\n\tif len(text) > 160 {\n\t\ttext = text[:157] + \"...\"\n\t}\n\tfmt.Printf(\"[sms to %s] %s\\n\", recipient, text)\n}\n\n// Alert and Reminder are refined abstractions: what the message means.\n// Each holds a Channel instead of being tied to one.\ntype Alert struct{ Channel Channel }\n\nfunc (a Alert) Notify(recipient, text string) {\n\ta.Channel.Deliver(recipient, \"URGENT\", strings.ToUpper(text))\n}\n\ntype Reminder struct {\n\tChannel Channel\n\tLead    time.Duration\n}\n\nfunc (r Reminder) Notify(recipient, text string) {\n\ttitle := fmt.Sprintf(\"Reminder, %.0f min left\", r.Lead.Minutes())\n\tr.Channel.Deliver(recipient, title, text)\n}\n\nfunc main() {\n\tAlert{Channel: SmsChannel{}}.Notify(\"Ola\", \"Payment for order 1042 failed\")\n\tReminder{Channel: EmailChannel{}, Lead: 30 * time.Minute}.Notify(\"Ola\", \"Your pierogi arrive soon\")\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"notifications.py"},"content":[{"type":"text","text":"from abc import ABC, abstractmethod\nfrom datetime import timedelta\nfrom typing import Protocol\n\n\nclass Channel(Protocol):\n    \"\"\"Implementor: how a message travels.\"\"\"\n\n    def deliver(self, recipient: str, title: str, body: str) -> None: ...\n\n\nclass EmailChannel:\n    def deliver(self, recipient: str, title: str, body: str) -> None:\n        print(f\"[email to {recipient}] Subject: {title} | {body}\")\n\n\nclass SmsChannel:\n    def deliver(self, recipient: str, title: str, body: str) -> None:\n        # SMS has no subject line and a hard length limit.\n        text = f\"{title}: {body}\"\n        print(f\"[sms to {recipient}] {text if len(text) <= 160 else text[:157] + '...'}\")\n\n\nclass Notice(ABC):\n    \"\"\"Abstraction: what the message means. It holds a channel instead of inheriting one.\"\"\"\n\n    def __init__(self, channel: Channel) -> None:\n        self.channel = channel\n\n    @abstractmethod\n    def notify(self, recipient: str, text: str) -> None: ...\n\n\nclass Alert(Notice):\n    def notify(self, recipient: str, text: str) -> None:\n        self.channel.deliver(recipient, \"URGENT\", text.upper())\n\n\nclass Reminder(Notice):\n    def __init__(self, channel: Channel, lead: timedelta) -> None:\n        super().__init__(channel)\n        self.lead = lead\n\n    def notify(self, recipient: str, text: str) -> None:\n        minutes = int(self.lead.total_seconds() // 60)\n        self.channel.deliver(recipient, f\"Reminder, {minutes} min left\", text)\n\n\nif __name__ == \"__main__\":\n    Alert(SmsChannel()).notify(\"Ola\", \"Payment for order 1042 failed\")\n    Reminder(EmailChannel(), timedelta(minutes=30)).notify(\"Ola\", \"Your pierogi arrive soon\")"}]}]}]},"toc":[{"id":"the-problem-emailurgentalert-smsurgentalert-pushurgentalert","text":"The problem: EmailUrgentAlert, SmsUrgentAlert, PushUrgentAlert…","level":2,"locked":false},{"id":"the-solution-two-hierarchies-and-a-reference-between-them","text":"The solution: two hierarchies and a reference between them","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":"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":"quick-check","text":"Quick check","level":2,"locked":true},{"id":"summary","text":"Summary","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":34,"visibleBlocks":15,"resources":[{"id":"6b0857be3c96f2d34d0b4229","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/bridge","embedUrl":null,"title":"Bridge","description":"Bridge is a structural design pattern that lets you split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["bridge"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:02.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857b23c96f2d34d0b3538","type":"repo","provider":"github","url":"https://github.com/sohamkamani/javascript-design-patterns-for-humans","embedUrl":null,"title":"sohamkamani/javascript-design-patterns-for-humans","description":"An ultra-simplified explanation of design patterns implemented in javascript","author":"sohamkamani","thumbnailUrl":"https://opengraph.githubassets.com/1/sohamkamani/javascript-design-patterns-for-humans","durationSec":null,"lang":"en","topics":["bridge"],"techs":["javascript"],"tags":["bridge-pattern","design-patterns","factory-pattern","javascript"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2017-02-21T08:10:03.000Z","popularity":71,"verifiedAt":"2026-11-26T10:57:25.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:50.215Z","updatedAt":"2026-11-26T16:00:50.215Z"},{"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"},{"id":"6b0857b13c96f2d34d0b33a1","type":"repo","provider":"github","url":"https://github.com/iluwatar/java-design-patterns","embedUrl":null,"title":"iluwatar/java-design-patterns","description":"Design patterns implemented in Java","author":"iluwatar","thumbnailUrl":"https://opengraph.githubassets.com/1/iluwatar/java-design-patterns","durationSec":null,"lang":"en","topics":[],"techs":["java"],"tags":["awesome-list","design-patterns","hacktoberfest","java","principles","snippets","snippets-collection","snippets-library"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2014-08-09T16:45:18.000Z","popularity":96,"verifiedAt":"2026-11-26T10:57:25.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:49.541Z","updatedAt":"2026-11-26T16:00:49.541Z"}],"challenges":[{"id":"6b0857af5a2625e44ecaad13","slug":"design-patterns-basics-quiz","title":"Design patterns – basics","summary":"Six questions about classic GoF patterns: groups, intent and differences.","servedLang":"en","availableLangs":["pl","en"],"kind":"quiz","category":null,"status":"published","difficulty":"easy","topics":["builder","adapter","strategy","decorator","composite","facade","observer"],"techs":["general"],"tags":["quiz","gof","basics"],"languages":[],"questionCount":6,"xp":10,"stats":{"attempts":1,"solves":1,"solutions":0,"comments":0},"solveRate":100,"publishedAt":"2026-11-26T16:00:47.960Z"},{"id":"6b0857af5a2625e44ecaad0d","slug":"discount-strategy","title":"Discount strategy","summary":"Interchangeable discount algorithms in a checkout: percentage, threshold and \"best of\", swapped at runtime.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":null,"status":"published","difficulty":"medium","topics":["strategy"],"techs":["python","typescript"],"tags":["strategy","e-commerce","behavioral"],"languages":["python","typescript"],"questionCount":null,"xp":20,"stats":{"attempts":1,"solves":1,"solutions":1,"comments":0},"solveRate":100,"publishedAt":"2026-11-26T16:00:47.764Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"gof-structural","title":"GoF structural patterns","items":[{"slug":"adapter","title":"Adapter – how to get along with code that speaks another language","current":false},{"slug":"bridge","title":"Bridge – two axes of change without a class explosion","current":true},{"slug":"composite","title":"Composite – trees in which a leaf and a branch look the same","current":false},{"slug":"decorator","title":"Decorator – adding behaviour layer by layer","current":false},{"slug":"facade","title":"Facade – one simple entry point to a complex subsystem","current":false},{"slug":"flyweight","title":"Flyweight – how to fit 60,000 stadium seats in memory","current":false},{"slug":"proxy","title":"Proxy – a stand-in that controls access to the real object","current":false}]}],"prev":{"slug":"adapter","title":"Adapter – how to get along with code that speaks another language"},"next":{"slug":"composite","title":"Composite – trees in which a leaf and a branch look the same"},"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}]}}