{"slug":"factory-method","group":"creational","title":"Metoda wytwórcza","short":"Podklasy decydują, jaki obiekt powstaje – kod wywołujący zna tylko wspólny interfejs.","icon":"factory","aliases":[],"order":101,"status":"available","articleCount":3,"groupTitle":"Wzorce kreacyjne","intro":"","servedLang":"pl","primaryArticle":{"id":"6b08bd3480884893657cc960","slug":"factory-method","title":"Metoda wytwórcza (Factory Method) – niech podklasa zdecyduje, co powstaje","summary":"Metoda wytwórcza oddziela algorytm, który używa obiektu, od decyzji, jaki dokładnie obiekt powstanie. Przykład z systemu rezerwacji biletów w C#, TypeScript, Javie, Go i Pythonie.","servedLang":"pl","availableLangs":["pl","en"],"topics":["factory-method","abstract-factory","template-method"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","creational","factory-method","polymorphism"],"level":"intermediate","kind":"article","access":"public","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":10,"stats":{"views":6,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:56.030Z","updatedAt":"2026-11-27T13:05:24.185Z","challengeCount":1,"quizCount":0},"articles":[{"id":"6b08bd2e80884893657cc8d4","slug":"abstract-factory","title":"Fabryka abstrakcyjna (Abstract Factory) – całe rodziny obiektów, które do siebie pasują","summary":"Fabryka abstrakcyjna tworzy komplet powiązanych obiektów jednej rodziny i pilnuje, by nikt nie pomieszał elementów z różnych zestawów. Przykład z integracją dwóch operatorów płatności.","servedLang":"pl","availableLangs":["pl","en"],"topics":["abstract-factory","factory-method","singleton"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","creational","abstract-factory","product-families"],"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":10,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:50.779Z","updatedAt":"2026-11-27T10:05:03.622Z","relation":{"position":1,"primary":false,"mainTopic":{"slug":"abstract-factory","title":"Fabryka abstrakcyjna"}}},{"id":"6b08bd3480884893657cc96a","slug":"flyweight","title":"Pyłek (Flyweight) – jak zmieścić w pamięci 60 tysięcy miejsc na stadionie","summary":"Pyłek oddziela stan wspólny dla wielu obiektów od stanu unikalnego i współdzieli ten pierwszy. Przykład mapy miejsc stadionu w systemie rezerwacji biletów w C#, TypeScript, Javie, Go i Pythonie.","servedLang":"pl","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":11,"stats":{"views":6,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:56.361Z","updatedAt":"2026-11-27T13:06:02.992Z","relation":{"position":3,"primary":false,"mainTopic":{"slug":"flyweight","title":"Pyłek"}}}],"challenges":[{"id":"6b0857af5a2625e44ecaad0a","slug":"notification-factory","title":"Fabryka powiadomień","summary":"Zaimplementuj Metodę wytwórczą: każdy serwis powiadomień sam decyduje, jaki kanał (e-mail, SMS, push) tworzy.","servedLang":"pl","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"}],"resources":[{"id":"6b0857a53c96f2d34d0b321d","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=EcFVTgRHJLM","embedUrl":"https://www.youtube-nocookie.com/embed/EcFVTgRHJLM","title":"Factory Method Pattern – Design Patterns (ep 4)","description":"","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/EcFVTgRHJLM/hqdefault.jpg","durationSec":null,"lang":"en","topics":["factory-method"],"techs":["general"],"tags":[],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"seed","publishedAt":null,"popularity":0,"verifiedAt":"2026-11-26T00:00:00.000Z","curated":true,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:37.643Z","updatedAt":"2026-11-26T16:00:37.643Z"},{"id":"6b0857be3c96f2d34d0b41dd","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/factory-method","embedUrl":null,"title":"Factory Method","description":"Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["factory-method"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":80,"verifiedAt":"2026-11-26T11:25:59.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857c33c96f2d34d0b4658","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL6030812W","embedUrl":null,"title":"Design Patterns: Elements of Reusable Object-Oriented Software","description":"","author":"Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson","thumbnailUrl":"https://covers.openlibrary.org/b/id/6601119-L.jpg","durationSec":null,"lang":"en","topics":["factory-method","abstract-factory","builder","prototype","singleton","adapter","bridge","composite","decorator","facade","flyweight","proxy","chain-of-responsibility","command","iterator","mediator","memento","observer","state","strategy","template-method","visitor"],"techs":["general"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"1995-01-01T00:00:00.000Z","popularity":71,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"},{"id":"6b0857c33c96f2d34d0b4666","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL16942701W","embedUrl":null,"title":"Head First design patterns","description":"","author":"Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates","thumbnailUrl":"https://covers.openlibrary.org/b/id/388950-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":["java"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2004-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":"6b0857c83c96f2d34d0b49f2","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=IlmOokWznyI","embedUrl":"https://www.youtube-nocookie.com/embed/IlmOokWznyI","title":"Design Patterns in Dynamic Languages | Code Walks 016","description":"Do dynamically typed languages really need design patterns? 02:43 The short version of the argument 03:04 Strategy pattern 05:25 Factory pattern GEAR USED ► MIC: RØDE SmartLav+ http://amzn.to/21nVI3o ► CAMERA: iPhone 6 http://amzn.to/1UeVCXv Original upload date: Jun 24, 2016","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/IlmOokWznyI/hqdefault.jpg","durationSec":null,"lang":"en","topics":["strategy"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2016-07-16T09:26:14.000Z","popularity":59,"verifiedAt":"2026-11-26T10:57:18.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857be3c96f2d34d0b4215","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/factory-method","embedUrl":null,"title":"Metoda wytwórcza / Factory Method","description":"Metoda wytwórcza jest kreacyjnym wzorcem projektowym, który udostępnia interfejs do tworzenia obiektów w ramach klasy bazowej, ale pozwala podklasom zmieniać typ tworzonych obiektów.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["factory-method"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:26:07.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}],"resourceGroups":[{"type":"video","items":[{"id":"6b0857a53c96f2d34d0b321d","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=EcFVTgRHJLM","embedUrl":"https://www.youtube-nocookie.com/embed/EcFVTgRHJLM","title":"Factory Method Pattern – Design Patterns (ep 4)","description":"","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/EcFVTgRHJLM/hqdefault.jpg","durationSec":null,"lang":"en","topics":["factory-method"],"techs":["general"],"tags":[],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"seed","publishedAt":null,"popularity":0,"verifiedAt":"2026-11-26T00:00:00.000Z","curated":true,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:37.643Z","updatedAt":"2026-11-26T16:00:37.643Z"},{"id":"6b0857c83c96f2d34d0b49f2","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=IlmOokWznyI","embedUrl":"https://www.youtube-nocookie.com/embed/IlmOokWznyI","title":"Design Patterns in Dynamic Languages | Code Walks 016","description":"Do dynamically typed languages really need design patterns? 02:43 The short version of the argument 03:04 Strategy pattern 05:25 Factory pattern GEAR USED ► MIC: RØDE SmartLav+ http://amzn.to/21nVI3o ► CAMERA: iPhone 6 http://amzn.to/1UeVCXv Original upload date: Jun 24, 2016","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/IlmOokWznyI/hqdefault.jpg","durationSec":null,"lang":"en","topics":["strategy"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2016-07-16T09:26:14.000Z","popularity":59,"verifiedAt":"2026-11-26T10:57:18.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"}]},{"type":"article","items":[{"id":"6b0857be3c96f2d34d0b41dd","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/factory-method","embedUrl":null,"title":"Factory Method","description":"Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["factory-method"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":80,"verifiedAt":"2026-11-26T11:25:59.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857be3c96f2d34d0b4215","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/factory-method","embedUrl":null,"title":"Metoda wytwórcza / Factory Method","description":"Metoda wytwórcza jest kreacyjnym wzorcem projektowym, który udostępnia interfejs do tworzenia obiektów w ramach klasy bazowej, ale pozwala podklasom zmieniać typ tworzonych obiektów.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["factory-method"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:26:07.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}]},{"type":"book","items":[{"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":"6b0857c33c96f2d34d0b4666","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL16942701W","embedUrl":null,"title":"Head First design patterns","description":"","author":"Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates","thumbnailUrl":"https://covers.openlibrary.org/b/id/388950-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":["java"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2004-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"}]}],"siblings":[{"slug":"factory-method","title":"Metoda wytwórcza","icon":"factory","status":"available","current":true},{"slug":"abstract-factory","title":"Fabryka abstrakcyjna","icon":"boxes","status":"available","current":false},{"slug":"builder","title":"Budowniczy","icon":"hammer","status":"available","current":false},{"slug":"prototype","title":"Prototyp","icon":"copy","status":"available","current":false},{"slug":"singleton","title":"Singleton","icon":"circle-dot","status":"available","current":false}]}