{"id":"6b08bd3c80884893657cc9f1","slug":"prototype","title":"Prototyp (Prototype) – nowy obiekt jako kopia gotowego wzorca","summary":"Prototyp tworzy obiekty przez klonowanie skonfigurowanego egzemplarza zamiast budowania ich od zera. Wyjaśniamy różnicę między kopią płytką a głęboką na przykładzie szablonów egzaminów.","servedLang":"pl","availableLangs":["pl","en"],"topics":["prototype","abstract-factory","memento"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","creational","prototype","cloning","deep-copy"],"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":9,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:04.737Z","updatedAt":"2026-11-27T10:04:59.218Z","requestedLang":"pl","theme":{"hero":"classic","heroMedia":null,"accent":"green","background":"dots","weaveResources":true,"toc":"right"},"seoDescription":"Wzorzec Prototyp (Prototype) – klonowanie obiektów, kopia płytka i głęboka, rejestr prototypów, kod w C#, TypeScript, Java, Go i Python, pułapki Cloneable, structuredClone i copy.deepcopy.","wordCount":1784,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Czasem najprościej utworzyć obiekt, biorąc podobny i zmieniając kilka szczegółów. "},{"type":"text","text":"Prototyp","marks":[{"type":"bold"}]},{"type":"text","text":" (ang. "},{"type":"text","text":"Prototype","marks":[{"type":"italic"}]},{"type":"text","text":") robi z tego wzorzec: obiekt sam umie się skopiować, a kod, który potrzebuje nowego egzemplarza, nie musi znać jego klasy ani wszystkich parametrów konfiguracji."}]},{"type":"callout","attrs":{"variant":"info","title":"W skrócie"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Obiekt udostępnia metodę "},{"type":"text","text":"clone()","marks":[{"type":"code"}]},{"type":"text","text":", która zwraca jego niezależną kopię."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Gotowe, skonfigurowane egzemplarze (prototypy) trzymasz w rejestrze i klonujesz na żądanie."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Najważniejsza decyzja to głębokość kopii: płytka kopia współdzieli zagnieżdżone obiekty z oryginałem."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"problem-egzamin-dla-grupy-b"},"content":[{"type":"text","text":"Problem: egzamin dla grupy B"}]},{"type":"paragraph","content":[{"type":"text","text":"Na platformie kursów programowania prowadzący przygotowuje egzamin: tytuł, limit czasu, kilkadziesiąt pytań, każde z listą odpowiedzi, ustawienia losowania kolejności. Dla grupy B chce tego samego egzaminu z dwiema zmienionymi odpowiedziami. Pierwsza wersja funkcji „Duplikuj” wyglądała tak:"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"duplicate-exam.ts"},"content":[{"type":"text","text":"function duplicate(exam: Exam): Exam {\n  // copies the fields, but the questions array is the same object!\n  return { ...exam, title: exam.title + \" (copy)\" };\n}\n\nconst groupB = duplicate(midterm);\ngroupB.questions[3].options.push(\"None of the above\"); // midterm changes too"}]},{"type":"paragraph","content":[{"type":"text","text":"Operator rozwinięcia ("},{"type":"text","text":"spread","marks":[{"type":"italic"}]},{"type":"text","text":") kopiuje tylko pierwszy poziom. Lista pytań jest współdzielona, więc edycja wersji dla grupy B po cichu zmienia egzamin grupy A – błąd wychodzi na jaw dopiero, gdy studenci widzą odpowiedź, której nie powinno tam być. Drugi problem: kod duplikujący musi znać wszystkie pola egzaminu i aktualizować się przy każdej zmianie klasy."}]},{"type":"heading","attrs":{"level":2,"id":"rozwiazanie-obiekt-ktory-umie-sie-sklonowac"},"content":[{"type":"text","text":"Rozwiązanie: obiekt, który umie się sklonować"}]},{"type":"paragraph","content":[{"type":"text","text":"Odpowiedzialność za kopiowanie przenosimy do samego obiektu. "},{"type":"text","text":"Exam.clone()","marks":[{"type":"code"}]},{"type":"text","text":" wie, które pola można skopiować wprost (tytuł, limit czasu), a które trzeba sklonować rekurencyjnie (pytania, a w nich listy odpowiedzi). Gotowe szablony – „kolokwium”, „egzamin końcowy”, „quiz na rozgrzewkę” – trzymamy w rejestrze i klonujemy, zamiast budować od zera."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"classDiagram\n  direction LR\n  class Prototype~T~ {\n    <<interface>>\n    +clone() T\n  }\n  class Exam {\n    +title\n    +timeLimit\n    +questions\n    +clone() Exam\n  }\n  class Question {\n    +text\n    +options\n    +clone() Question\n  }\n  class TemplateRegistry {\n    +get(name) Exam\n  }\n  Prototype <|.. Exam\n  Prototype <|.. Question\n  Exam *-- Question\n  TemplateRegistry o-- Exam : prototypy","caption":"Prototyp z rejestrem szablonów"}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Rola"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"W przykładzie"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Odpowiedzialność"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Prototyp ("},{"type":"text","text":"Prototype","marks":[{"type":"italic"}]},{"type":"text","text":")"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"IPrototype<T>","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"deklaruje operację klonowania"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Prototyp konkretny"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Exam","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Question","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"implementuje kopię, decydując o jej głębokości"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Rejestr (opcjonalny)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"słownik szablonów"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"przechowuje skonfigurowane prototypy pod nazwami"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Klient"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"widok „Duplikuj egzamin”"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"prosi o kopię, nie znając szczegółów konstrukcji"}]}]}]}]},{"type":"section","attrs":{"background":"dots","width":"wide","padding":"m"},"content":[{"type":"heading","attrs":{"level":2,"id":"plytka-czy-gleboka-kopia"},"content":[{"type":"text","text":"Płytka czy głęboka kopia?"}]},{"type":"paragraph","content":[{"type":"text","text":"To serce wzorca. "},{"type":"text","text":"Kopia płytka","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"shallow copy","marks":[{"type":"italic"}]},{"type":"text","text":") tworzy nowy obiekt, ale pola wskazujące na inne obiekty nadal wskazują na te same egzemplarze. "},{"type":"text","text":"Kopia głęboka","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"deep copy","marks":[{"type":"italic"}]},{"type":"text","text":") rekurencyjnie kopiuje również obiekty zagnieżdżone. Pola niezmienne – napisy, liczby, rekordy bez setterów – można bezpiecznie współdzielić; kolekcje i obiekty zmienne trzeba sklonować."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  subgraph P[\"Kopia płytka\"]\n    A1[\"Szablon\"] --> L1[(\"Lista pytań\")]\n    B1[\"Kopia\"] --> L1\n  end\n  subgraph G[\"Kopia głęboka\"]\n    A2[\"Szablon\"] --> L2[(\"Lista pytań\")]\n    B2[\"Kopia\"] --> L3[(\"Własna lista pytań\")]\n  end","caption":"Kopia płytka współdzieli listę pytań, kopia głęboka ma własną"}}]},{"type":"heading","attrs":{"level":2,"id":"implementacja-w-pieciu-jezykach"},"content":[{"type":"text","text":"Implementacja w pięciu językach"}]},{"type":"paragraph","content":[{"type":"text","text":"Każdy język ma tu swoje pułapki: rekord w C# z "},{"type":"text","text":"with","marks":[{"type":"code"}]},{"type":"text","text":" i "},{"type":"text","text":"dataclasses.replace()","marks":[{"type":"code"}]},{"type":"text","text":" w Pythonie robią kopię płytką, operator rozwinięcia w TypeScripcie także, a w Go przypisanie struktury kopiuje ją, ale wycinki ("},{"type":"text","text":"slices","marks":[{"type":"italic"}]},{"type":"text","text":") dalej wskazują na tę samą tablicę. Dlatego każda implementacja klonuje kolekcje jawnie."}]},{"type":"codeGroup","attrs":{"title":"Exam.Clone()"},"content":[{"type":"codeBlock","attrs":{"language":"csharp","filename":"Exams.cs"},"content":[{"type":"text","text":"var registry = new Dictionary<string, Exam>\n{\n    [\"midterm\"] = new Exam(\"Midterm\", TimeSpan.FromMinutes(45),\n        [new Question(\"What does SRP stand for?\", [\"Single Responsibility\", \"Simple Routing\"])]),\n};\n\nvar groupA = registry[\"midterm\"].Clone();\ngroupA.Title = \"Midterm - group A\";\ngroupA.Questions[0].Options.Add(\"Strict Rendering Pipeline\");\n\nvar template = registry[\"midterm\"];\nConsole.WriteLine($\"{template.Questions[0].Options.Count} vs {groupA.Questions[0].Options.Count}\");\n\npublic interface IPrototype<out T>\n{\n    T Clone();\n}\n\npublic sealed class Question(string text, List<string> options) : IPrototype<Question>\n{\n    public string Text { get; set; } = text;\n    public List<string> Options { get; } = options;\n\n    public Question Clone() => new(Text, [.. Options]);\n}\n\npublic sealed class Exam(string title, TimeSpan timeLimit, List<Question> questions)\n    : IPrototype<Exam>\n{\n    public string Title { get; set; } = title;\n    public TimeSpan TimeLimit { get; set; } = timeLimit;\n    public List<Question> Questions { get; } = questions;\n\n    // Deep copy: the clone gets its own questions, so editing it never touches the template.\n    public Exam Clone() => new(Title, TimeLimit, Questions.Select(q => q.Clone()).ToList());\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"exams.ts"},"content":[{"type":"text","text":"class Question {\n  constructor(public text: string, public readonly options: string[]) {}\n\n  clone(): Question {\n    return new Question(this.text, [...this.options]);\n  }\n}\n\nclass Exam {\n  constructor(\n    public title: string,\n    public timeLimitMin: number,\n    public readonly questions: Question[],\n  ) {}\n\n  // Deep copy: the clone gets its own questions, so editing it never touches the template.\n  clone(): Exam {\n    return new Exam(this.title, this.timeLimitMin, this.questions.map((q) => q.clone()));\n  }\n}\n\nconst registry = new Map<string, Exam>([\n  [\n    \"midterm\",\n    new Exam(\"Midterm\", 45, [\n      new Question(\"What does SRP stand for?\", [\"Single Responsibility\", \"Simple Routing\"]),\n    ]),\n  ],\n]);\n\nconst template = registry.get(\"midterm\")!;\nconst groupA = template.clone();\ngroupA.title = \"Midterm - group A\";\ngroupA.questions[0].options.push(\"Strict Rendering Pipeline\");\nconsole.log(template.questions[0].options.length, groupA.questions[0].options.length); // 2 3"}]},{"type":"codeBlock","attrs":{"language":"java","filename":"Exams.java"},"content":[{"type":"text","text":"import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\n\nfinal class Question {\n    String text;\n    final List<String> options;\n\n    Question(String text, List<String> options) {\n        this.text = text;\n        this.options = new ArrayList<>(options);\n    }\n\n    // Copy constructors/methods are the idiomatic Java alternative to Cloneable.\n    Question copy() { return new Question(text, options); }\n}\n\nfinal class Exam {\n    String title;\n    int timeLimitMin;\n    final List<Question> questions;\n\n    Exam(String title, int timeLimitMin, List<Question> questions) {\n        this.title = title;\n        this.timeLimitMin = timeLimitMin;\n        this.questions = new ArrayList<>(questions);\n    }\n\n    // Deep copy: the clone gets its own questions, so editing it never touches the template.\n    Exam copy() {\n        return new Exam(title, timeLimitMin, questions.stream().map(Question::copy).toList());\n    }\n}\n\npublic class Exams {\n    public static void main(String[] args) {\n        var srp = new Question(\"What does SRP stand for?\", List.of(\"Single Responsibility\", \"Simple Routing\"));\n        Map<String, Exam> registry = Map.of(\"midterm\", new Exam(\"Midterm\", 45, List.of(srp)));\n\n        Exam template = registry.get(\"midterm\");\n        Exam groupA = template.copy();\n        groupA.title = \"Midterm - group A\";\n        groupA.questions.get(0).options.add(\"Strict Rendering Pipeline\");\n\n        System.out.println(template.questions.get(0).options.size() + \" vs \"\n            + groupA.questions.get(0).options.size());\n    }\n}"}]},{"type":"codeBlock","attrs":{"language":"go","filename":"exams.go"},"content":[{"type":"text","text":"package main\n\nimport \"fmt\"\n\ntype Question struct {\n\tText    string\n\tOptions []string\n}\n\ntype Exam struct {\n\tTitle        string\n\tTimeLimitMin int\n\tQuestions    []Question\n}\n\n// Clone makes a deep copy. A plain assignment (b := a) copies the struct,\n// but the Questions and Options slices would still be shared with the template.\nfunc (e Exam) Clone() Exam {\n\tc := e\n\tc.Questions = make([]Question, len(e.Questions))\n\tfor i, q := range e.Questions {\n\t\tq.Options = append([]string(nil), q.Options...)\n\t\tc.Questions[i] = q\n\t}\n\treturn c\n}\n\nfunc main() {\n\tregistry := map[string]Exam{\n\t\t\"midterm\": {\n\t\t\tTitle:        \"Midterm\",\n\t\t\tTimeLimitMin: 45,\n\t\t\tQuestions: []Question{\n\t\t\t\t{Text: \"What does SRP stand for?\", Options: []string{\"Single Responsibility\", \"Simple Routing\"}},\n\t\t\t},\n\t\t},\n\t}\n\n\ttemplate := registry[\"midterm\"]\n\tgroupA := template.Clone()\n\tgroupA.Title = \"Midterm - group A\"\n\tgroupA.Questions[0].Text = \"SRP means...\"\n\tgroupA.Questions[0].Options = append(groupA.Questions[0].Options, \"Strict Rendering Pipeline\")\n\n\tfmt.Println(template.Questions[0].Text, len(template.Questions[0].Options))\n\tfmt.Println(groupA.Questions[0].Text, len(groupA.Questions[0].Options))\n}"}]},{"type":"codeBlock","attrs":{"language":"python","filename":"exams.py"},"content":[{"type":"text","text":"import copy\nfrom dataclasses import dataclass, field, replace\nfrom typing import Any, Self\n\n\n@dataclass\nclass Question:\n    text: str\n    options: list[str] = field(default_factory=list)\n\n\n@dataclass\nclass Exam:\n    title: str\n    time_limit_min: int\n    questions: list[Question] = field(default_factory=list)\n\n    def clone(self, **changes: Any) -> Self:\n        # deepcopy gives the clone its own questions; replace() then applies the edits\n        return replace(copy.deepcopy(self), **changes)\n\n\nregistry = {\n    \"midterm\": Exam(\n        \"Midterm\", 45, [Question(\"What does SRP stand for?\", [\"Single Responsibility\", \"Simple Routing\"])]\n    ),\n}\n\nif __name__ == \"__main__\":\n    template = registry[\"midterm\"]\n    group_a = template.clone(title=\"Midterm - group A\")\n    group_a.questions[0].options.append(\"Strict Rendering Pipeline\")\n    print(len(template.questions[0].options), len(group_a.questions[0].options))  # 2 3\n\n    shallow = replace(template, title=\"Shallow copy\")  # replace() alone is shallow\n    print(\"shares questions:\", shallow.questions is template.questions)  # True"}]}]}]},"toc":[{"id":"problem-egzamin-dla-grupy-b","text":"Problem: egzamin dla grupy B","level":2,"locked":false},{"id":"rozwiazanie-obiekt-ktory-umie-sie-sklonowac","text":"Rozwiązanie: obiekt, który umie się sklonować","level":2,"locked":false},{"id":"plytka-czy-gleboka-kopia","text":"Płytka czy głęboka kopia?","level":2,"locked":false},{"id":"implementacja-w-pieciu-jezykach","text":"Implementacja w pięciu językach","level":2,"locked":false},{"id":"krok-po-kroku","text":"Krok po kroku","level":2,"locked":true},{"id":"kiedy-stosowac-a-kiedy-nie","text":"Kiedy stosować, a kiedy nie","level":2,"locked":true},{"id":"powiazania-z-innymi-wzorcami","text":"Powiązania z innymi wzorcami","level":2,"locked":true},{"id":"w-praktyce","text":"W praktyce","level":2,"locked":true},{"id":"szybki-test","text":"Szybki test","level":2,"locked":true},{"id":"podsumowanie","text":"Podsumowanie","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":34,"visibleBlocks":14,"resources":[{"id":"6b0857bf3c96f2d34d0b42d8","type":"article","provider":"web","url":"https://gameprogrammingpatterns.com/prototype.html","embedUrl":null,"title":"Prototype · Design Patterns Revisited · Game Programming Patterns","description":"","author":"Robert Nystrom","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["prototype"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:37.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T23:13:50.482Z"},{"id":"6b0857bf3c96f2d34d0b4242","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/prototype","embedUrl":null,"title":"Prototype","description":"Prototype is a creational design pattern that lets you copy existing objects without making your code dependent on their classes.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["prototype"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:00.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"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"}],"challenges":[{"id":"6b093ddfbd4755deb67ee09b","slug":"serialize-binary-tree","title":"Serializacja drzewa binarnego","summary":"Zapisujemy drzewo binarne do napisu i odtwarzamy je z powrotem – z pustymi poddrzewami, ujemnymi liczbami i drzewami głębokimi na tysiące poziomów. Projekt formatu, BFS i pułapka rekurencji.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"hard","topics":["memento"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["trees","binary-tree","bfs","dfs","serialization","design"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":40,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:55.586Z"},{"id":"6b093dc191bd8fbaf2a0c8c8","slug":"game-checkpoint-memento","title":"Punkty kontrolne w grze","summary":"Zapis i odtwarzanie stanu bohatera przez Pamiątkę – niezmienne migawki bez współdzielonych list, opiekun z ograniczoną pojemnością i ochrona przed wczytaniem cudzego zapisu.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"easy","topics":["memento"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["memento","snapshots","undo","immutability","behavioral"],"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.224Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"gof-creational","title":"Wzorce kreacyjne GoF","items":[{"slug":"factory-method","title":"Metoda wytwórcza (Factory Method) – niech podklasa zdecyduje, co powstaje","current":false},{"slug":"abstract-factory","title":"Fabryka abstrakcyjna (Abstract Factory) – całe rodziny obiektów, które do siebie pasują","current":false},{"slug":"builder","title":"Budowniczy (Builder) – złożone obiekty krok po kroku","current":false},{"slug":"prototype","title":"Prototyp (Prototype) – nowy obiekt jako kopia gotowego wzorca","current":true},{"slug":"singleton","title":"Singleton – jedna instancja i powody, by oddać ją kontenerowi DI","current":false}]}],"prev":{"slug":"builder","title":"Budowniczy (Builder) – złożone obiekty krok po kroku"},"next":{"slug":"singleton","title":"Singleton – jedna instancja i powody, by oddać ją kontenerowi DI"},"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":"Autorytet","articles":63},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Autorytet","articles":53},{"key":"python","title":"Python","level":5,"levelLabel":"Autorytet","articles":52},{"key":"java","title":"Java","level":5,"levelLabel":"Autorytet","articles":38}]}}