{"id":"6b08bd2f80884893657cc8f2","slug":"builder","title":"Builder – complex objects step by step","summary":"Builder collects an object's parameters in readable steps and hands over a finished, valid product only in build(). A catering order example in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["builder","abstract-factory","composite"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","creational","builder","fluent-interface","immutability"],"level":"beginner","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":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:51.940Z","updatedAt":"2026-11-27T13:04:58.174Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"green","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"The Builder design pattern – the problem of a ten-parameter constructor, fluent interfaces, the Director, diagrams, code in C#, TypeScript, Java, Go and Python, examples from .NET, Java, Go and Python.","wordCount":2347,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Some objects cannot sensibly be created with a single constructor call: they have many fields, some of them optional, and validity depends on how values combine. "},{"type":"text","text":"Builder","marks":[{"type":"bold"}]},{"type":"text","text":" splits creation into named steps and hands over the finished object only at the end – once everything has been checked."}]},{"type":"callout","attrs":{"variant":"info","title":"In short"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"You assemble the object with clearly named methods ("},{"type":"text","text":"forCustomer()","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"add()","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"deliverAt()","marks":[{"type":"code"}]},{"type":"text","text":"), and "},{"type":"text","text":"build()","marks":[{"type":"code"}]},{"type":"text","text":" returns the finished product."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Validation of the whole happens in one place – an invalid object is never created."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The product can be immutable, because the builder collects all the data beforehand."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-a-constructor-nobody-knows-how-to-call"},"content":[{"type":"text","text":"The problem: a constructor nobody knows how to call"}]},{"type":"paragraph","content":[{"type":"text","text":"Halina's pierogi place takes catering orders from companies. An order has a customer, a list of items, a delivery time, an optional note, invoice details, eco packaging, a discount… The class grew together with the business, and today creating one looks like this:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"checkout.ts"},"content":[{"type":"text","text":"const order = new CateringOrder(\"Acme Sp. z o.o.\", lines, slot, undefined, false, true, undefined, 0);"}]},{"type":"paragraph","content":[{"type":"text","text":"What does "},{"type":"text","text":"true","marks":[{"type":"code"}]},{"type":"text","text":" in sixth position mean? Is "},{"type":"text","text":"0","marks":[{"type":"code"}]},{"type":"text","text":" the discount or the number of cutlery sets? Developers cope with constructor overloads (the "},{"type":"text","text":"telescoping constructor","marks":[{"type":"italic"}]},{"type":"text","text":") or set fields with setters after creation – but then, for a moment, an order without a delivery time exists, and someone may accidentally save it to the database. There is also no place for the \"at least one item\" rule."}]},{"type":"heading","attrs":{"level":2,"id":"the-solution-a-separate-object-that-collects-the-data"},"content":[{"type":"text","text":"The solution: a separate object that collects the data"}]},{"type":"paragraph","content":[{"type":"text","text":"We extract a "},{"type":"text","text":"CateringOrderBuilder","marks":[{"type":"code"}]},{"type":"text","text":" class. Each method sets one thing and returns the builder itself, so calls chain together – a so-called "},{"type":"text","text":"fluent interface","marks":[{"type":"italic"}]},{"type":"text","text":". The "},{"type":"text","text":"build()","marks":[{"type":"code"}]},{"type":"text","text":" method checks the whole and only then creates an immutable "},{"type":"text","text":"CateringOrder","marks":[{"type":"code"}]},{"type":"text","text":"."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  participant K as Client code\n  participant B as CateringOrderBuilder\n  participant O as CateringOrder\n  K->>B: forCustomer(\"Acme\")\n  K->>B: add(\"pierogi ruskie\", 40)\n  K->>B: add(\"pierogi z mięsem\", 20)\n  K->>B: deliverAt(12:30)\n  K->>B: build()\n  B->>B: validate the whole\n  B->>O: create with complete data\n  B-->>K: finished, immutable order","caption":"Building an order step by step"}},{"type":"paragraph","content":[{"type":"text","text":"In the original GoF formulation, Builder has one more role: the "},{"type":"text","text":"Director","marks":[{"type":"bold"}]},{"type":"text","text":", which knows the order of steps. The same director can drive different builders and obtain different representations – for example, the same steps produce an order for the system or a printout for the kitchen."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"classDiagram\n  direction LR\n  class OfficeLunchDirector {\n    +compose(builder, people)\n  }\n  class OrderSteps {\n    <<interface>>\n    +forCustomer(name)\n    +add(dish, quantity)\n    +deliverAt(time)\n  }\n  class CateringOrderBuilder {\n    +build() CateringOrder\n  }\n  class KitchenTicketBuilder {\n    +build() string\n  }\n  OfficeLunchDirector --> OrderSteps : drives\n  OrderSteps <|.. CateringOrderBuilder\n  OrderSteps <|.. KitchenTicketBuilder","caption":"Classic GoF structure: one director, different representations"}},{"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":"Builder"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderSteps","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"declares the construction steps"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Concrete builder"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"CateringOrderBuilder","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"KitchenTicketBuilder","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"collects data, validates, creates the product"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Product"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"CateringOrder","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the finished, immutable object"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Director (optional)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OfficeLunchDirector","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"knows the order of steps for typical cases"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"implementation-in-five-languages"},"content":[{"type":"text","text":"Implementation in five languages"}]},{"type":"paragraph","content":[{"type":"text","text":"Below is today's most common variant – a fluent builder without a director. In Java the builder is a static nested class and the product's constructor is private, so there is simply no other way to get an order. In Go, instead of exceptions, the builder remembers the first error and returns it from "},{"type":"text","text":"Build()","marks":[{"type":"code"}]},{"type":"text","text":" – which keeps the call chain readable."}]},{"type":"codeGroup","attrs":{"title":"CateringOrderBuilder"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"CateringOrder.cs"},"content":[{"type":"text","text":"var order = new CateringOrderBuilder()\n    .ForCustomer(\"Acme Sp. z o.o.\")\n    .Add(\"pierogi ruskie\", 40)\n    .Add(\"pierogi z mięsem\", 20)\n    .DeliverAt(new DateTime(2026, 12, 4, 12, 30, 0))\n    .WithNote(\"Leave at reception\")\n    .Build();\nConsole.WriteLine($\"{order.Customer}: {order.Lines.Sum(l => l.Quantity)} pcs at {order.DeliveryAt:HH:mm}\");\n\npublic sealed record OrderLine(string Dish, int Quantity);\n\npublic sealed record CateringOrder(\n    string Customer, IReadOnlyList<OrderLine> Lines, DateTime DeliveryAt, string? Note);\n\npublic sealed class CateringOrderBuilder\n{\n    private readonly List<OrderLine> _lines = [];\n    private string? _customer;\n    private DateTime? _deliveryAt;\n    private string? _note;\n\n    public CateringOrderBuilder ForCustomer(string customer) { _customer = customer; return this; }\n    public CateringOrderBuilder DeliverAt(DateTime when) { _deliveryAt = when; return this; }\n    public CateringOrderBuilder WithNote(string note) { _note = note; return this; }\n\n    public CateringOrderBuilder Add(string dish, int quantity)\n    {\n        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(quantity);\n        _lines.Add(new OrderLine(dish, quantity));\n        return this;\n    }\n\n    // Build() is the only way to get an order, so an invalid one never exists.\n    public CateringOrder Build()\n    {\n        if (_customer is null) throw new InvalidOperationException(\"Customer is required\");\n        if (_lines.Count == 0) throw new InvalidOperationException(\"Add at least one dish\");\n        if (_deliveryAt is null) throw new InvalidOperationException(\"Delivery time is required\");\n        return new CateringOrder(_customer, _lines.ToArray(), _deliveryAt.Value, _note);\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"catering-order.ts"},"content":[{"type":"text","text":"interface OrderLine {\n  readonly dish: string;\n  readonly quantity: number;\n}\n\ninterface CateringOrder {\n  readonly customer: string;\n  readonly lines: readonly OrderLine[];\n  readonly deliveryAt: Date;\n  readonly note?: string;\n}\n\nclass CateringOrderBuilder {\n  private customer?: string;\n  private readonly lines: OrderLine[] = [];\n  private deliveryAt?: Date;\n  private note?: string;\n\n  forCustomer(customer: string): this {\n    this.customer = customer;\n    return this;\n  }\n\n  add(dish: string, quantity: number): this {\n    if (quantity <= 0) throw new RangeError(`Quantity of ${dish} must be positive`);\n    this.lines.push({ dish, quantity });\n    return this;\n  }\n\n  deliverAt(when: Date): this {\n    this.deliveryAt = when;\n    return this;\n  }\n\n  withNote(note: string): this {\n    this.note = note;\n    return this;\n  }\n\n  // build() is the only way to get an order, so an invalid one never exists.\n  build(): CateringOrder {\n    if (!this.customer) throw new Error(\"Customer is required\");\n    if (this.lines.length === 0) throw new Error(\"Add at least one dish\");\n    if (!this.deliveryAt) throw new Error(\"Delivery time is required\");\n    const { customer, deliveryAt, note } = this;\n    return Object.freeze({ customer, deliveryAt, note, lines: [...this.lines] });\n  }\n}\n\nconst order = new CateringOrderBuilder()\n  .forCustomer(\"Acme Sp. z o.o.\")\n  .add(\"pierogi ruskie\", 40)\n  .add(\"pierogi z mięsem\", 20)\n  .deliverAt(new Date(2026, 11, 4, 12, 30))\n  .build();\nconsole.log(order.customer, order.lines.length, order.deliveryAt.toISOString());"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"CateringOrder.java"},"content":[{"type":"text","text":"import java.time.LocalDateTime;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Objects;\n\npublic final class CateringOrder {\n    public record Line(String dish, int quantity) {}\n\n    private final String customer;\n    private final List<Line> lines;\n    private final LocalDateTime deliveryAt;\n    private final String note;\n\n    private CateringOrder(Builder b) {\n        customer = b.customer;\n        lines = List.copyOf(b.lines);\n        deliveryAt = b.deliveryAt;\n        note = b.note;\n    }\n\n    public static Builder builder() { return new Builder(); }\n\n    @Override\n    public String toString() {\n        int pieces = lines.stream().mapToInt(Line::quantity).sum();\n        return customer + \": \" + pieces + \" pcs at \" + deliveryAt.toLocalTime() + \" (\" + note + \")\";\n    }\n\n    public static final class Builder {\n        private final List<Line> lines = new ArrayList<>();\n        private String customer;\n        private LocalDateTime deliveryAt;\n        private String note;\n\n        private Builder() {}\n\n        public Builder forCustomer(String c) { customer = c; return this; }\n        public Builder deliverAt(LocalDateTime when) { deliveryAt = when; return this; }\n        public Builder withNote(String n) { note = n; return this; }\n\n        public Builder add(String dish, int quantity) {\n            if (quantity <= 0) throw new IllegalArgumentException(\"quantity must be positive\");\n            lines.add(new Line(dish, quantity));\n            return this;\n        }\n\n        // build() is the only way to get an order, so an invalid one never exists.\n        public CateringOrder build() {\n            Objects.requireNonNull(customer, \"customer is required\");\n            Objects.requireNonNull(deliveryAt, \"delivery time is required\");\n            if (lines.isEmpty()) throw new IllegalStateException(\"add at least one dish\");\n            return new CateringOrder(this);\n        }\n    }\n\n    public static void main(String[] args) {\n        System.out.println(CateringOrder.builder()\n            .forCustomer(\"Acme Sp. z o.o.\")\n            .add(\"pierogi ruskie\", 40)\n            .add(\"pierogi z mięsem\", 20)\n            .deliverAt(LocalDateTime.of(2026, 12, 4, 12, 30))\n            .withNote(\"Leave at reception\")\n            .build());\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"order.go"},"content":[{"type":"text","text":"package main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n)\n\ntype OrderLine struct {\n\tDish     string\n\tQuantity int\n}\n\ntype CateringOrder struct {\n\tCustomer   string\n\tLines      []OrderLine\n\tDeliveryAt time.Time\n\tNote       string\n}\n\n// OrderBuilder remembers the first problem and reports it in Build, so calls can be chained.\ntype OrderBuilder struct {\n\torder CateringOrder\n\terr   error\n}\n\nfunc NewOrder(customer string) *OrderBuilder {\n\treturn &OrderBuilder{order: CateringOrder{Customer: customer}}\n}\n\nfunc (b *OrderBuilder) Add(dish string, qty int) *OrderBuilder {\n\tif qty <= 0 && b.err == nil {\n\t\tb.err = fmt.Errorf(\"quantity of %q must be positive\", dish)\n\t}\n\tb.order.Lines = append(b.order.Lines, OrderLine{Dish: dish, Quantity: qty})\n\treturn b\n}\n\nfunc (b *OrderBuilder) DeliverAt(t time.Time) *OrderBuilder {\n\tb.order.DeliveryAt = t\n\treturn b\n}\n\nfunc (b *OrderBuilder) Build() (CateringOrder, error) {\n\tswitch {\n\tcase b.err != nil:\n\t\treturn CateringOrder{}, b.err\n\tcase b.order.Customer == \"\":\n\t\treturn CateringOrder{}, errors.New(\"customer is required\")\n\tcase len(b.order.Lines) == 0:\n\t\treturn CateringOrder{}, errors.New(\"add at least one dish\")\n\tcase b.order.DeliveryAt.IsZero():\n\t\treturn CateringOrder{}, errors.New(\"delivery time is required\")\n\t}\n\torder := b.order\n\torder.Lines = append([]OrderLine(nil), b.order.Lines...) // reusing the builder cannot mutate the order\n\treturn order, nil\n}\n\nfunc main() {\n\torder, err := NewOrder(\"Acme Sp. z o.o.\").\n\t\tAdd(\"pierogi ruskie\", 40).\n\t\tAdd(\"pierogi z mięsem\", 20).\n\t\tDeliverAt(time.Date(2026, 12, 4, 12, 30, 0, 0, time.Local)).\n\t\tBuild()\n\tif err != nil {\n\t\tfmt.Println(\"invalid order:\", err)\n\t\treturn\n\t}\n\tfmt.Println(order.Customer, len(order.Lines), order.DeliveryAt.Format(\"15:04\"))\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"catering_order.py"},"content":[{"type":"text","text":"from dataclasses import dataclass\nfrom datetime import datetime\nfrom typing import Self\n\n\n@dataclass(frozen=True)\nclass OrderLine:\n    dish: str\n    quantity: int\n\n\n@dataclass(frozen=True)\nclass CateringOrder:\n    customer: str\n    lines: tuple[OrderLine, ...]\n    delivery_at: datetime\n    note: str | None = None\n\n\nclass CateringOrderBuilder:\n    def __init__(self) -> None:\n        self._customer: str | None = None\n        self._lines: list[OrderLine] = []\n        self._delivery_at: datetime | None = None\n        self._note: str | None = None\n\n    def for_customer(self, customer: str) -> Self:\n        self._customer = customer\n        return self\n\n    def add(self, dish: str, quantity: int) -> Self:\n        if quantity <= 0:\n            raise ValueError(f\"quantity of {dish!r} must be positive\")\n        self._lines.append(OrderLine(dish, quantity))\n        return self\n\n    def deliver_at(self, when: datetime) -> Self:\n        self._delivery_at = when\n        return self\n\n    def with_note(self, note: str) -> Self:\n        self._note = note\n        return self\n\n    def build(self) -> CateringOrder:\n        # build() is the only way to get an order, so an invalid one never exists.\n        if self._customer is None or self._delivery_at is None:\n            raise ValueError(\"customer and delivery time are required\")\n        if not self._lines:\n            raise ValueError(\"add at least one dish\")\n        return CateringOrder(self._customer, tuple(self._lines), self._delivery_at, self._note)\n\n\nif __name__ == \"__main__\":\n    order = (\n        CateringOrderBuilder()\n        .for_customer(\"Acme Sp. z o.o.\")\n        .add(\"pierogi ruskie\", 40)\n        .add(\"pierogi z mięsem\", 20)\n        .deliver_at(datetime(2026, 12, 4, 12, 30))\n        .build()\n    )\n    print(order.customer, sum(line.quantity for line in order.lines), order.delivery_at.time())"}]}]}]},"toc":[{"id":"the-problem-a-constructor-nobody-knows-how-to-call","text":"The problem: a constructor nobody knows how to call","level":2,"locked":false},{"id":"the-solution-a-separate-object-that-collects-the-data","text":"The solution: a separate object that collects the data","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":37,"visibleBlocks":15,"resources":[{"id":"6b0857c33c96f2d34d0b4665","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL6223299W","embedUrl":null,"title":"Effective Java","description":"","author":"Joshua Bloch","thumbnailUrl":"https://covers.openlibrary.org/b/id/1176573-L.jpg","durationSec":null,"lang":"en","topics":[],"techs":["java"],"tags":["book"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2001-01-01T00:00:00.000Z","popularity":62,"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"},{"id":"6b0857be3c96f2d34d0b4201","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/builder","embedUrl":null,"title":"Builder","description":"Builder is a creational design pattern that lets you construct complex objects step by step. The pattern allows you to produce different types and representations of an object using the same construction code.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["builder"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:26:00.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857a43c96f2d34d0b320c","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=tv-_1er1mWI","embedUrl":"https://www.youtube-nocookie.com/embed/tv-_1er1mWI","title":"10 Design Patterns Explained in 10 Minutes","description":"","author":"Fireship","thumbnailUrl":"https://i.ytimg.com/vi/tv-_1er1mWI/hqdefault.jpg","durationSec":null,"lang":"en","topics":["singleton","prototype","builder","factory-method","facade","proxy","iterator","observer","mediator","state"],"techs":["typescript"],"tags":[],"price":"free","featured":true,"featuredOrder":5,"packageName":null,"source":"seed","publishedAt":null,"popularity":0,"verifiedAt":"2026-11-26T00:00:00.000Z","curated":true,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:36.249Z","updatedAt":"2026-11-26T16:00:36.249Z"}],"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":"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":"6b093dc191bd8fbaf2a0c8cc","slug":"http-request-builder","title":"HTTP request builder","summary":"A fluent builder for an immutable HTTP request – defaults, header normalisation, validation in build() and a reusable builder.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"easy","topics":["builder"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["builder","fluent-interface","immutability","validation","creational"],"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.386Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"gof-creational","title":"GoF creational patterns","items":[{"slug":"factory-method","title":"Factory Method – let the subclass decide what gets created","current":false},{"slug":"abstract-factory","title":"Abstract Factory – whole families of objects that fit together","current":false},{"slug":"builder","title":"Builder – complex objects step by step","current":true},{"slug":"prototype","title":"Prototype – a new object as a copy of a ready-made template","current":false},{"slug":"singleton","title":"Singleton – one instance, and the reasons to hand it to a DI container","current":false}]}],"prev":{"slug":"abstract-factory","title":"Abstract Factory – whole families of objects that fit together"},"next":{"slug":"prototype","title":"Prototype – a new object as a copy of a ready-made template"},"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}]}}