{"id":"6b08bd3480884893657cc96a","slug":"flyweight","title":"Flyweight – how to fit 60,000 stadium seats in memory","summary":"Flyweight separates the state shared by many objects from the state unique to each one, and shares the former. A stadium seat map example from a ticket booking system in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["flyweight","composite","singleton","factory-method"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","flyweight","memory","performance","interning"],"level":"advanced","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":12,"stats":{"views":6,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:56.361Z","updatedAt":"2026-11-27T13:06:02.992Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"indigo","background":"grid","weaveResources":true,"toc":"right"},"seoDescription":"The Flyweight design pattern – intrinsic and extrinsic state, the flyweight factory, a memory saving estimate, code in C#, TypeScript, Java, Go and Python, string interning, Integer.valueOf, unique.Make in Go, __slots__ in Python.","wordCount":2203,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Most GoF patterns are about readable, flexible code. "},{"type":"text","text":"Flyweight","marks":[{"type":"bold"}]},{"type":"text","text":" is the exception – it is an optimisation pattern. When you have hundreds of thousands of similar objects that differ in only a few fields, Flyweight pulls the common part out into a single shared instance and leaves only what is truly unique in each object."}]},{"type":"callout","attrs":{"variant":"info","title":"In short"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"You split an object's state into "},{"type":"text","text":"intrinsic","marks":[{"type":"bold"}]},{"type":"text","text":" (shared, immutable – category, price, icon) and "},{"type":"text","text":"extrinsic","marks":[{"type":"bold"}]},{"type":"text","text":" (unique – row, number)."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Intrinsic state goes into a shared flyweight object; a factory makes sure each one exists only once."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Flyweights must be immutable – otherwise changing one object changes thousands."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-a-stadium-map-that-eats-memory"},"content":[{"type":"text","text":"The problem: a stadium map that eats memory"}]},{"type":"paragraph","content":[{"type":"text","text":"A ticket booking system shows an interactive stadium map: 60,000 seats, each with a category (VIP, standard, accessible), a price, a colour and an SVG icon used for drawing. The first version of the model was simple:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"seat.ts"},"content":[{"type":"text","text":"class Seat {\n  constructor(\n    public row: number,\n    public number: number,\n    public category: string, // the same 6 values repeated 60 000 times\n    public price: number,\n    public color: string,\n    public iconSvg: string,  // ~2 KB of path data, copied into every seat\n  ) {}\n}"}]},{"type":"paragraph","content":[{"type":"text","text":"The icon is about 2 KB of path data, repeated in each of the 60 thousand seats. A server that caches the maps of several events at once starts to choke, and the app in a phone browser stutters when scrolling."}]},{"type":"chart","attrs":{"type":"bar","title":"Seat map memory: copies versus shared types","caption":"Illustrative estimate assuming about 2 KB of seat-type data and 48 B per seat with a reference; real values depend on the runtime.","unit":"MB","data":{"labels":["Hall, 5,000 seats","Arena, 20,000 seats","Stadium, 60,000 seats"],"series":[{"name":"Copies in every seat","values":[10.4,41.8,125.3]},{"name":"Flyweight","values":[0.25,0.97,2.89]}]}}},{"type":"heading","attrs":{"level":2,"id":"the-solution-share-what-repeats"},"content":[{"type":"text","text":"The solution: share what repeats"}]},{"type":"paragraph","content":[{"type":"text","text":"We notice that a stadium has only a handful of seat "},{"type":"text","text":"types","marks":[{"type":"bold"}]},{"type":"text","text":" but thousands of "},{"type":"text","text":"seats","marks":[{"type":"bold"}]},{"type":"text","text":". Category, price, colour and icon belong to the type – that is intrinsic state. Row and number belong to a specific seat – that is extrinsic state. We extract an immutable "},{"type":"text","text":"SeatType","marks":[{"type":"code"}]},{"type":"text","text":" class, and "},{"type":"text","text":"Seat","marks":[{"type":"code"}]},{"type":"text","text":" stores only the row, the number and a reference to its type. A "},{"type":"text","text":"SeatTypeFactory","marks":[{"type":"code"}]},{"type":"text","text":" returns an existing type instead of creating a new one."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"classDiagram\n  direction LR\n  class SeatTypeFactory {\n    -types Map\n    +get(category) SeatType\n  }\n  class SeatType {\n    <<flyweight>>\n    +category\n    +price\n    +color\n    +iconSvg\n  }\n  class Seat {\n    +row\n    +number\n    +type SeatType\n    +describe()\n  }\n  SeatTypeFactory o-- SeatType : caches\n  Seat --> SeatType : shares","caption":"Thousands of lightweight seats point to a few shared types"}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"State"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Example"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Where it lives"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"How many copies"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Intrinsic"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"category, price, colour, icon"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SeatType","marks":[{"type":"code"}]},{"type":"text","text":" (the flyweight)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"one per type – here 2"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Extrinsic"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"row, number, booking status"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Seat","marks":[{"type":"code"}]},{"type":"text","text":" (the context)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"one per seat – 60,000"}]}]}]}]},{"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":"Flyweight"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SeatType","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"immutable, shared intrinsic state"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Flyweight factory"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SeatTypeFactory","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"returns an existing instance or creates it once"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Context"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Seat","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"extrinsic state + a reference to the flyweight"}]}]}]},{"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 map view"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"creates seats through the factory, supplies extrinsic state"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"implementation-in-five-languages"},"content":[{"type":"text","text":"Implementation in five languages"}]},{"type":"paragraph","content":[{"type":"text","text":"Each example creates 60,000 seats, and at the end the factory reports that only two types exist. In C# "},{"type":"text","text":"Seat","marks":[{"type":"code"}]},{"type":"text","text":" is a struct ("},{"type":"text","text":"readonly record struct","marks":[{"type":"code"}]},{"type":"text","text":"), so the seats are not even separate heap objects; in Python "},{"type":"text","text":"slots=True","marks":[{"type":"code"}]},{"type":"text","text":" removes the attribute dictionary from every instance."}]},{"type":"codeGroup","attrs":{"title":"SeatTypeFactory"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"SeatMap.cs"},"content":[{"type":"text","text":"var factory = new SeatTypeFactory();\nvar seats = new List<Seat>(capacity: 60_000);\nfor (var row = 1; row <= 200; row++)\n    for (var number = 1; number <= 300; number++)\n        seats.Add(new Seat(row, number, factory.Get(row <= 20 ? \"VIP\" : \"Standard\")));\n\nConsole.WriteLine($\"{seats.Count} seats, {factory.Count} shared seat types\");\nConsole.WriteLine(seats[0].Describe());\n\n// Flyweight: intrinsic, immutable state shared by thousands of seats.\npublic sealed record SeatType(string Category, decimal Price, string Color, string IconSvg);\n\n// Context: extrinsic state unique to each seat, plus a reference to the flyweight.\npublic readonly record struct Seat(int Row, int Number, SeatType Type)\n{\n    public string Describe() => $\"Row {Row}, seat {Number}: {Type.Category}, {Type.Price} PLN\";\n}\n\n// Flyweight factory: returns an existing instance instead of creating duplicates.\npublic sealed class SeatTypeFactory\n{\n    private readonly Dictionary<string, SeatType> _types = new();\n\n    public int Count => _types.Count;\n\n    public SeatType Get(string category)\n    {\n        if (!_types.TryGetValue(category, out var type))\n        {\n            type = category == \"VIP\"\n                ? new SeatType(\"VIP\", 450m, \"#C9A227\", LoadIcon(\"vip\"))\n                : new SeatType(\"Standard\", 120m, \"#4263EB\", LoadIcon(\"standard\"));\n            _types[category] = type;\n        }\n        return type;\n    }\n\n    private static string LoadIcon(string name) => $\"<svg><!-- {name}: ~2 KB of path data --></svg>\";\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"seat-map.ts"},"content":[{"type":"text","text":"// Flyweight: intrinsic, immutable state shared by thousands of seats.\ninterface SeatType {\n  readonly category: string;\n  readonly price: number;\n  readonly color: string;\n  readonly iconSvg: string;\n}\n\n// Context: extrinsic state unique to each seat, plus a reference to the flyweight.\nclass Seat {\n  constructor(readonly row: number, readonly number: number, readonly type: SeatType) {}\n\n  describe(): string {\n    return `Row ${this.row}, seat ${this.number}: ${this.type.category}, ${this.type.price} PLN`;\n  }\n}\n\n// Flyweight factory: returns an existing instance instead of creating duplicates.\nclass SeatTypeFactory {\n  private readonly types = new Map<string, SeatType>();\n\n  get size(): number {\n    return this.types.size;\n  }\n\n  get(category: \"VIP\" | \"Standard\"): SeatType {\n    let type = this.types.get(category);\n    if (!type) {\n      type = Object.freeze(\n        category === \"VIP\"\n          ? { category, price: 450, color: \"#C9A227\", iconSvg: loadIcon(\"vip\") }\n          : { category, price: 120, color: \"#4263EB\", iconSvg: loadIcon(\"standard\") },\n      );\n      this.types.set(category, type);\n    }\n    return type;\n  }\n}\n\nconst loadIcon = (name: string) => `<svg><!-- ${name}: ~2 KB of path data --></svg>`;\n\nconst factory = new SeatTypeFactory();\nconst seats: Seat[] = [];\nfor (let row = 1; row <= 200; row++) {\n  for (let n = 1; n <= 300; n++) seats.push(new Seat(row, n, factory.get(row <= 20 ? \"VIP\" : \"Standard\")));\n}\nconsole.log(`${seats.length} seats, ${factory.size} shared seat types`);\nconsole.log(seats[0].describe());"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"SeatMap.java"},"content":[{"type":"text","text":"import java.math.BigDecimal;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\n// Flyweight: intrinsic, immutable state shared by thousands of seats.\nrecord SeatType(String category, BigDecimal price, String color, String iconSvg) {}\n\n// Context: extrinsic state unique to each seat, plus a reference to the flyweight.\nrecord Seat(int row, int number, SeatType type) {\n    String describe() {\n        return \"Row \" + row + \", seat \" + number + \": \" + type.category() + \", \" + type.price() + \" PLN\";\n    }\n}\n\n// Flyweight factory: returns an existing instance instead of creating duplicates.\nfinal class SeatTypeFactory {\n    private final Map<String, SeatType> types = new HashMap<>();\n\n    SeatType get(String category) {\n        return types.computeIfAbsent(category, c -> c.equals(\"VIP\")\n            ? new SeatType(\"VIP\", new BigDecimal(\"450\"), \"#C9A227\", loadIcon(\"vip\"))\n            : new SeatType(\"Standard\", new BigDecimal(\"120\"), \"#4263EB\", loadIcon(\"standard\")));\n    }\n\n    int count() { return types.size(); }\n\n    private static String loadIcon(String name) { return \"<svg><!-- \" + name + \": ~2 KB of path data --></svg>\"; }\n}\n\npublic class SeatMap {\n    public static void main(String[] args) {\n        var factory = new SeatTypeFactory();\n        List<Seat> seats = new ArrayList<>(60_000);\n        for (int row = 1; row <= 200; row++)\n            for (int number = 1; number <= 300; number++)\n                seats.add(new Seat(row, number, factory.get(row <= 20 ? \"VIP\" : \"Standard\")));\n\n        System.out.println(seats.size() + \" seats, \" + factory.count() + \" shared seat types\");\n        System.out.println(seats.get(0).describe());\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"seatmap.go"},"content":[{"type":"text","text":"package main\n\nimport \"fmt\"\n\n// SeatType is the flyweight: intrinsic, immutable state shared by thousands of seats.\ntype SeatType struct {\n\tCategory string\n\tPrice    int\n\tColor    string\n\tIconSVG  string\n}\n\n// Seat is the context: small extrinsic state plus a pointer to the shared flyweight.\ntype Seat struct {\n\tRow, Number int32\n\tType        *SeatType\n}\n\n// SeatTypeFactory returns an existing instance instead of creating duplicates.\ntype SeatTypeFactory struct{ types map[string]*SeatType }\n\nfunc NewSeatTypeFactory() *SeatTypeFactory {\n\treturn &SeatTypeFactory{types: make(map[string]*SeatType)}\n}\n\nfunc (f *SeatTypeFactory) Get(category string) *SeatType {\n\tif t, ok := f.types[category]; ok {\n\t\treturn t\n\t}\n\tt := &SeatType{Category: \"Standard\", Price: 120, Color: \"#4263EB\", IconSVG: loadIcon(\"standard\")}\n\tif category == \"VIP\" {\n\t\tt = &SeatType{Category: \"VIP\", Price: 450, Color: \"#C9A227\", IconSVG: loadIcon(\"vip\")}\n\t}\n\tf.types[category] = t\n\treturn t\n}\n\nfunc loadIcon(name string) string { return \"<svg><!-- \" + name + \": ~2 KB of path data --></svg>\" }\n\nfunc main() {\n\tfactory := NewSeatTypeFactory()\n\tseats := make([]Seat, 0, 60_000)\n\tfor row := int32(1); row <= 200; row++ {\n\t\tfor n := int32(1); n <= 300; n++ {\n\t\t\tcategory := \"Standard\"\n\t\t\tif row <= 20 {\n\t\t\t\tcategory = \"VIP\"\n\t\t\t}\n\t\t\tseats = append(seats, Seat{Row: row, Number: n, Type: factory.Get(category)})\n\t\t}\n\t}\n\tfmt.Println(len(seats), \"seats,\", len(factory.types), \"shared seat types\")\n\ts := seats[0]\n\tfmt.Printf(\"Row %d, seat %d: %s, %d PLN\\n\", s.Row, s.Number, s.Type.Category, s.Type.Price)\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"seat_map.py"},"content":[{"type":"text","text":"from dataclasses import dataclass\n\n\n@dataclass(frozen=True, slots=True)\nclass SeatType:\n    \"\"\"Flyweight: intrinsic, immutable state shared by thousands of seats.\"\"\"\n\n    category: str\n    price: int\n    color: str\n    icon_svg: str\n\n\n@dataclass(frozen=True, slots=True)\nclass Seat:\n    \"\"\"Context: extrinsic state unique to each seat, plus a reference to the flyweight.\"\"\"\n\n    row: int\n    number: int\n    type: SeatType\n\n    def describe(self) -> str:\n        return f\"Row {self.row}, seat {self.number}: {self.type.category}, {self.type.price} PLN\"\n\n\nclass SeatTypeFactory:\n    \"\"\"Returns an existing instance instead of creating duplicates.\"\"\"\n\n    def __init__(self) -> None:\n        self._types: dict[str, SeatType] = {}\n\n    def get(self, category: str) -> SeatType:\n        if category not in self._types:\n            if category == \"VIP\":\n                self._types[category] = SeatType(\"VIP\", 450, \"#C9A227\", load_icon(\"vip\"))\n            else:\n                self._types[category] = SeatType(\"Standard\", 120, \"#4263EB\", load_icon(\"standard\"))\n        return self._types[category]\n\n    def __len__(self) -> int:\n        return len(self._types)\n\n\ndef load_icon(name: str) -> str:\n    return f\"<svg><!-- {name}: ~2 KB of path data --></svg>\"\n\n\nif __name__ == \"__main__\":\n    factory = SeatTypeFactory()\n    seats = [\n        Seat(row, number, factory.get(\"VIP\" if row <= 20 else \"Standard\"))\n        for row in range(1, 201)\n        for number in range(1, 301)\n    ]\n    print(f\"{len(seats)} seats, {len(factory)} shared seat types\")\n    print(seats[0].describe())"}]}]}]},"toc":[{"id":"the-problem-a-stadium-map-that-eats-memory","text":"The problem: a stadium map that eats memory","level":2,"locked":false},{"id":"the-solution-share-what-repeats","text":"The solution: share what repeats","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":35,"visibleBlocks":15,"resources":[{"id":"6b0857bf3c96f2d34d0b4272","type":"article","provider":"web","url":"https://gameprogrammingpatterns.com/flyweight.html","embedUrl":null,"title":"Flyweight · Design Patterns Revisited · Game Programming Patterns","description":"","author":"Robert Nystrom","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["flyweight"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:36.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T23:13:50.321Z"},{"id":"6b0857bf3c96f2d34d0b4271","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/flyweight","embedUrl":null,"title":"Flyweight","description":"Flyweight is a structural design pattern that lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["flyweight"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:03.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857b23c96f2d34d0b35b8","type":"repo","provider":"github","url":"https://github.com/Habrador/Unity-Programming-Patterns","embedUrl":null,"title":"Habrador/Unity-Programming-Patterns","description":"Implementations of programming design patterns in Unity with examples in C# when to use them.","author":"Habrador","thumbnailUrl":"https://opengraph.githubassets.com/1/Habrador/Unity-Programming-Patterns","durationSec":null,"lang":"en","topics":["prototype","singleton","flyweight","command","observer"],"techs":["dotnet"],"tags":["architecture","command-pattern","computer-science","design-patterns","factory-pattern","flyweight-pattern","software-architecture","game-programming-pattern","object-pool","object-pool-pattern"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2020-06-14T12:53:46.000Z","popularity":64,"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":"6b0857c33c96f2d34d0b4685","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL19650342W","embedUrl":null,"title":"Game Programming Patterns","description":"","author":"Robert Nystrom","thumbnailUrl":"https://covers.openlibrary.org/b/id/8566115-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"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2011-01-01T00:00:00.000Z","popularity":54,"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":"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":"6b093ddebd4755deb67ee06e","slug":"flatten-object","title":"Flatten a nested object","summary":"Turn a nested JSON object into a flat path → value map (e.g. for a CSV export or a config diff). Recursion or an explicit stack, leaves and empty containers.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"easy","topics":["composite"],"techs":["typescript","javascript","python"],"tags":["recursion","objects","dfs","javascript"],"languages":["typescript","javascript","python"],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:54.109Z"},{"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":"6b0857af5a2625e44ecaad0a","slug":"notification-factory","title":"Notification factory","summary":"Implement Factory Method: every notification service decides which channel (e-mail, SMS, push) it creates.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":null,"status":"published","difficulty":"easy","topics":["factory-method"],"techs":["typescript","javascript"],"tags":["factory-method","notifications","creational"],"languages":["typescript","javascript"],"questionCount":null,"xp":10,"stats":{"attempts":1,"solves":1,"solutions":1,"comments":0},"solveRate":100,"publishedAt":"2026-11-26T16:00:47.675Z"}],"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":false},{"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":true},{"slug":"proxy","title":"Proxy – a stand-in that controls access to the real object","current":false}]}],"prev":{"slug":"facade","title":"Facade – one simple entry point to a complex subsystem"},"next":{"slug":"proxy","title":"Proxy – a stand-in that controls access to the real object"},"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}]}}