{"slug":"state","group":"behavioral","title":"Stan","short":"Zachowanie obiektu zmienia się razem z jego stanem – zamiast rozrośniętych instrukcji warunkowych.","icon":"toggle-right","aliases":[],"order":307,"status":"available","articleCount":2,"groupTitle":"Wzorce behawioralne","intro":"","servedLang":"pl","primaryArticle":{"id":"6b08bd3d80884893657cca0f","slug":"state","title":"Stan (State): obiekt, który zmienia zachowanie razem z etapem życia","summary":"Wzorzec Stan na przykładzie zamówienia w pierogarni: Nowe, Opłacone, W kuchni, Dostarczone i Anulowane jako osobne obiekty, które same pilnują dozwolonych przejść. Maszyna stanów bez drabinki if-ów, kod w pięciu językach.","servedLang":"pl","availableLangs":["pl","en"],"topics":["state"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","state","state-machine","lifecycle"],"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":12,"stats":{"views":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:05.764Z","updatedAt":"2026-11-27T10:04:41.885Z","challengeCount":1,"quizCount":0},"articles":[{"id":"6b093dbf91bd8fbaf2a0c8a7","slug":"circuit-breaker","title":"Circuit breaker: bezpiecznik, który zamienia wolną awarię w szybką","summary":"Wzorzec Circuit Breaker od podstaw: stany zamknięty, otwarty i półotwarty, progi i okna, filtrowanie błędów biznesowych, współpraca z limitem czasu, ponowieniami i grodziami. Konfiguracja w Polly, opossum, Resilience4j, gobreaker i pybreaker.","servedLang":"pl","availableLangs":["pl","en"],"topics":["circuit-breaker","microservices","state"],"techs":["dotnet","typescript","java","go","python"],"tags":["resilience","circuit-breaker","fault-tolerance","timeouts","retries","bulkhead","distributed-systems"],"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":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T08:22:23.815Z","updatedAt":"2026-11-27T10:04:40.224Z","relation":{"position":2,"primary":false,"mainTopic":{"slug":"circuit-breaker","title":"Bezpiecznik (Circuit Breaker)"}}}],"challenges":[{"id":"6b093dc291bd8fbaf2a0c8e4","slug":"subscription-state","title":"Cykl życia subskrypcji jako maszyna stanów","summary":"Subskrypcja SaaS przechodzi przez okres próbny, aktywność, zaległość i anulowanie. Każdy stan to osobna klasa, która sama decyduje o przejściach – bez rozrastającego się switcha.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"medium","topics":["state"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["state","state-machine","subscriptions","billing","behavioral"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":20,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:26.723Z"}],"resources":[{"id":"6b0857bf3c96f2d34d0b428b","type":"article","provider":"web","url":"https://gameprogrammingpatterns.com/state.html","embedUrl":null,"title":"State · Design Patterns Revisited · Game Programming Patterns","description":"","author":"Robert Nystrom","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:37.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T23:13:50.442Z"},{"id":"6b0857bf3c96f2d34d0b428a","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/state","embedUrl":null,"title":"Stan / State","description":"Stan to behawioralny wzorzec projektowy pozwalający obiektowi zmienić swoje zachowanie gdy zmieni się jego stan wewnętrzny. Wygląda to tak, jakby obiekt zmienił swoją klasę.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:13.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857c83c96f2d34d0b4a41","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=26xrX113KZc","embedUrl":"https://www.youtube-nocookie.com/embed/26xrX113KZc","title":"Mauro Servienti - Talk Session: Welcome to the (State) Machine","description":"Explore DDD 2019 - Denver, Sept. 16-20 Stateless all the things, they say. In the last few years we've been brainwashed: design stateless systems, otherwise they cannot scale, they cannot be highly available, and they are hard to maintain and evolve. In a nutshell stateful is bad. However complex…","author":"Explore DDD","thumbnailUrl":"https://i.ytimg.com/vi/26xrX113KZc/hqdefault.jpg","durationSec":null,"lang":"en","topics":["ddd-strategic-design"],"techs":["general"],"tags":["software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2019-10-05T18:52:49.000Z","popularity":57,"verifiedAt":"2026-11-26T10:53:11.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"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":"6b0857bf3c96f2d34d0b4246","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/state","embedUrl":null,"title":"State","description":"State is a behavioral design pattern that lets an object alter its behavior when its internal state changes. It appears as if the object changed its class.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:06.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857bd3c96f2d34d0b41c8","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/episode-16-lets-talk-about-the-state-of-things/id467641329?i=1000701187896","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id467641329?i=1000701187896","title":"Episode 16. Let’s talk about the STATE of things. A brief intro to the State pattern","description":"The State pattern is very useful, it's just hard to spot, and at the beginning a little hard to understand. On this podcast we cover the state pattern with a specific example of its use, plus tips on how to spot when to use it (really that's the...","author":"Java Pub House","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts221/v4/ca/24/a7/ca24a7a6-e926-cc14-223a-444cf4127b70/mza_6810655170352985611.png/600x600bb.jpg","durationSec":null,"lang":"en","topics":["state"],"techs":["java"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2012-02-03T13:06:45.000Z","popularity":21,"verifiedAt":"2026-11-26T10:58:02.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}],"resourceGroups":[{"type":"video","items":[{"id":"6b0857c83c96f2d34d0b4a41","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=26xrX113KZc","embedUrl":"https://www.youtube-nocookie.com/embed/26xrX113KZc","title":"Mauro Servienti - Talk Session: Welcome to the (State) Machine","description":"Explore DDD 2019 - Denver, Sept. 16-20 Stateless all the things, they say. In the last few years we've been brainwashed: design stateless systems, otherwise they cannot scale, they cannot be highly available, and they are hard to maintain and evolve. In a nutshell stateful is bad. However complex…","author":"Explore DDD","thumbnailUrl":"https://i.ytimg.com/vi/26xrX113KZc/hqdefault.jpg","durationSec":null,"lang":"en","topics":["ddd-strategic-design"],"techs":["general"],"tags":["software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2019-10-05T18:52:49.000Z","popularity":57,"verifiedAt":"2026-11-26T10:53:11.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"}]},{"type":"podcast","items":[{"id":"6b0857bd3c96f2d34d0b41c8","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/episode-16-lets-talk-about-the-state-of-things/id467641329?i=1000701187896","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id467641329?i=1000701187896","title":"Episode 16. Let’s talk about the STATE of things. A brief intro to the State pattern","description":"The State pattern is very useful, it's just hard to spot, and at the beginning a little hard to understand. On this podcast we cover the state pattern with a specific example of its use, plus tips on how to spot when to use it (really that's the...","author":"Java Pub House","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts221/v4/ca/24/a7/ca24a7a6-e926-cc14-223a-444cf4127b70/mza_6810655170352985611.png/600x600bb.jpg","durationSec":null,"lang":"en","topics":["state"],"techs":["java"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2012-02-03T13:06:45.000Z","popularity":21,"verifiedAt":"2026-11-26T10:58:02.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}]},{"type":"article","items":[{"id":"6b0857bf3c96f2d34d0b428b","type":"article","provider":"web","url":"https://gameprogrammingpatterns.com/state.html","embedUrl":null,"title":"State · Design Patterns Revisited · Game Programming Patterns","description":"","author":"Robert Nystrom","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:37.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T23:13:50.442Z"},{"id":"6b0857bf3c96f2d34d0b428a","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/state","embedUrl":null,"title":"Stan / State","description":"Stan to behawioralny wzorzec projektowy pozwalający obiektowi zmienić swoje zachowanie gdy zmieni się jego stan wewnętrzny. Wygląda to tak, jakby obiekt zmienił swoją klasę.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:13.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857bf3c96f2d34d0b4246","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/state","embedUrl":null,"title":"State","description":"State is a behavioral design pattern that lets an object alter its behavior when its internal state changes. It appears as if the object changed its class.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["state"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:06.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}]},{"type":"book","items":[{"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":"chain-of-responsibility","title":"Łańcuch zobowiązań","icon":"link","status":"available","current":false},{"slug":"command","title":"Polecenie","icon":"terminal","status":"available","current":false},{"slug":"iterator","title":"Iterator","icon":"list-ordered","status":"available","current":false},{"slug":"mediator","title":"Mediator","icon":"messages-square","status":"available","current":false},{"slug":"memento","title":"Pamiątka","icon":"save","status":"available","current":false},{"slug":"observer","title":"Obserwator","icon":"eye","status":"available","current":false},{"slug":"state","title":"Stan","icon":"toggle-right","status":"available","current":true},{"slug":"strategy","title":"Strategia","icon":"route","status":"available","current":false},{"slug":"template-method","title":"Metoda szablonowa","icon":"layout-template","status":"available","current":false},{"slug":"visitor","title":"Odwiedzający","icon":"footprints","status":"available","current":false}]}