{"slug":"decorator","group":"structural","title":"Decorator","short":"Adds behaviour by wrapping an object instead of multiplying subclasses.","icon":"layers","aliases":[],"order":204,"status":"available","articleCount":4,"groupTitle":"Structural patterns","intro":"","servedLang":"en","primaryArticle":{"id":"6b08bd3280884893657cc938","slug":"decorator","title":"Decorator – adding behaviour layer by layer","summary":"Decorator wraps an object in another object with the same interface and adds behaviour before or after the call. An example of caching, retries and logging for an exchange rate provider in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["decorator","proxy","chain-of-responsibility","composite"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","decorator","middleware","cross-cutting-concerns"],"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":11,"stats":{"views":3,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:54.428Z","updatedAt":"2026-11-27T13:08:21.545Z","challengeCount":1,"quizCount":1},"articles":[{"id":"6b08bd3d80884893657cc9fb","slug":"proxy","title":"Proxy – a stand-in that controls access to the real object","summary":"Proxy has the same interface as the real object and stands in front of it, deciding when – and whether – to pass a call on. An invoice archive example with access control and a lazy connection in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["proxy","decorator","adapter","facade"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","proxy","lazy-loading","access-control"],"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":11,"stats":{"views":4,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:05.076Z","updatedAt":"2026-11-27T13:04:42.349Z","relation":{"position":1,"primary":false,"mainTopic":{"slug":"proxy","title":"Proxy"}}},{"id":"6b08bd3180884893657cc91a","slug":"composite","title":"Composite – trees in which a leaf and a branch look the same","summary":"Composite lets you treat a single object and a whole group of objects in exactly the same way. A course curriculum example with modules and lessons in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["composite","decorator","iterator","visitor"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","composite","tree","recursion"],"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":11,"stats":{"views":3,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:53.346Z","updatedAt":"2026-11-27T13:05:54.209Z","relation":{"position":1,"primary":false,"mainTopic":{"slug":"composite","title":"Composite"}}},{"id":"6b08bd2f80884893657cc8de","slug":"adapter","title":"Adapter – how to get along with code that speaks another language","summary":"Adapter translates the interface of a foreign class into the interface your code expects. An example of integrating a third-party geocoding SDK in C#, TypeScript, Java, Go and Python.","servedLang":"en","availableLangs":["pl","en"],"topics":["adapter","facade","decorator","hexagonal-architecture"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","structural","adapter","integration","anti-corruption-layer"],"level":"beginner","kind":"article","access":"public","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":11,"stats":{"views":4,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:13:51.251Z","updatedAt":"2026-11-27T13:05:48.206Z","relation":{"position":2,"primary":false,"mainTopic":{"slug":"adapter","title":"Adapter"}}}],"challenges":[{"id":"6b093dddbd4755deb67ee061","slug":"debounce-throttle","title":"Debounce and throttle","summary":"Two classic frontend higher-order functions – debounce (call after silence) and throttle (at most once per period) – with cancel, flush, preserved this and injected timers.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"medium","topics":["decorator"],"techs":["typescript","javascript"],"tags":["javascript","closures","timers","event-loop","higher-order-functions"],"languages":["typescript","javascript"],"questionCount":null,"xp":20,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:53.681Z"},{"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"}],"resources":[{"id":"6b0857a53c96f2d34d0b321c","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=GCraGHx6gso","embedUrl":"https://www.youtube-nocookie.com/embed/GCraGHx6gso","title":"Decorator Pattern – Design Patterns (ep 3)","description":"","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/GCraGHx6gso/hqdefault.jpg","durationSec":null,"lang":"en","topics":["decorator"],"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.563Z","updatedAt":"2026-11-26T16:00:37.563Z"},{"id":"6b0857be3c96f2d34d0b4208","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/decorator","embedUrl":null,"title":"Decorator","description":"Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["decorator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:26:02.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857c73c96f2d34d0b4929","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=gsluG8NdCfw","embedUrl":"https://www.youtube-nocookie.com/embed/gsluG8NdCfw","title":"Building Your Own CQRS Pipeline With Decorators (Dropped MediatR!)","description":"Get the free Clean Architecture template: https://dub.sh/ca-template Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt So… you’ve removed MediatR. But how do you replace pipeline behaviors like logging and…","author":"Milan Jovanović","thumbnailUrl":"https://i.ytimg.com/vi/gsluG8NdCfw/hqdefault.jpg","durationSec":null,"lang":"en","topics":["decorator","modular-monolith","clean-architecture","cqrs"],"techs":["dotnet"],"tags":["design-patterns","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2025-05-16T11:01:28.000Z","popularity":65,"verifiedAt":"2026-11-26T10:54:01.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":"6b0857be3c96f2d34d0b4232","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/decorator","embedUrl":null,"title":"Dekorator / Decorator","description":"Dekorator to strukturalny wzorzec projektowy pozwalający dodawać nowe obowiązki obiektom poprzez umieszczanie tych obiektów w specjalnych obiektach opakowujących, które zawierają odpowiednie zachowania.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["decorator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:10.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857be3c96f2d34d0b41d8","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/episode-9-its-the-holidays-lets-decorate/id467641329?i=1000701187991","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id467641329?i=1000701187991","title":"Episode 9. It’s the Holidays! Let’s Decorate!","description":"In this episode we talk about the Decorator pattern and how it is applied. We cover a couple of caveats (especially when combined with the Observer pattern) and learn how to not be afraid of its verboseness. In all, it's the season of decorating, so...","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":["decorator","observer"],"techs":["java"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2011-12-02T09:56:11.000Z","popularity":10,"verifiedAt":"2026-11-26T11:04:06.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}],"resourceGroups":[{"type":"video","items":[{"id":"6b0857a53c96f2d34d0b321c","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=GCraGHx6gso","embedUrl":"https://www.youtube-nocookie.com/embed/GCraGHx6gso","title":"Decorator Pattern – Design Patterns (ep 3)","description":"","author":"Christopher Okhravi","thumbnailUrl":"https://i.ytimg.com/vi/GCraGHx6gso/hqdefault.jpg","durationSec":null,"lang":"en","topics":["decorator"],"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.563Z","updatedAt":"2026-11-26T16:00:37.563Z"},{"id":"6b0857c73c96f2d34d0b4929","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=gsluG8NdCfw","embedUrl":"https://www.youtube-nocookie.com/embed/gsluG8NdCfw","title":"Building Your Own CQRS Pipeline With Decorators (Dropped MediatR!)","description":"Get the free Clean Architecture template: https://dub.sh/ca-template Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt So… you’ve removed MediatR. But how do you replace pipeline behaviors like logging and…","author":"Milan Jovanović","thumbnailUrl":"https://i.ytimg.com/vi/gsluG8NdCfw/hqdefault.jpg","durationSec":null,"lang":"en","topics":["decorator","modular-monolith","clean-architecture","cqrs"],"techs":["dotnet"],"tags":["design-patterns","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2025-05-16T11:01:28.000Z","popularity":65,"verifiedAt":"2026-11-26T10:54:01.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"}]},{"type":"podcast","items":[{"id":"6b0857be3c96f2d34d0b41d8","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/episode-9-its-the-holidays-lets-decorate/id467641329?i=1000701187991","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id467641329?i=1000701187991","title":"Episode 9. It’s the Holidays! Let’s Decorate!","description":"In this episode we talk about the Decorator pattern and how it is applied. We cover a couple of caveats (especially when combined with the Observer pattern) and learn how to not be afraid of its verboseness. In all, it's the season of decorating, so...","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":["decorator","observer"],"techs":["java"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2011-12-02T09:56:11.000Z","popularity":10,"verifiedAt":"2026-11-26T11:04:06.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}]},{"type":"article","items":[{"id":"6b0857be3c96f2d34d0b4208","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/decorator","embedUrl":null,"title":"Decorator","description":"Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["decorator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:26:02.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857be3c96f2d34d0b4232","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/decorator","embedUrl":null,"title":"Dekorator / Decorator","description":"Dekorator to strukturalny wzorzec projektowy pozwalający dodawać nowe obowiązki obiektom poprzez umieszczanie tych obiektów w specjalnych obiektach opakowujących, które zawierają odpowiednie zachowania.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["decorator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":70,"verifiedAt":"2026-11-26T11:26:10.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}]},{"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":"adapter","title":"Adapter","icon":"plug","status":"available","current":false},{"slug":"bridge","title":"Bridge","icon":"spline","status":"available","current":false},{"slug":"composite","title":"Composite","icon":"network","status":"available","current":false},{"slug":"decorator","title":"Decorator","icon":"layers","status":"available","current":true},{"slug":"facade","title":"Facade","icon":"building","status":"available","current":false},{"slug":"flyweight","title":"Flyweight","icon":"feather","status":"available","current":false},{"slug":"proxy","title":"Proxy","icon":"shield","status":"available","current":false}]}