{"slug":"visitor","group":"behavioral","title":"Visitor","short":"Adds new operations to an object structure without modifying its classes.","icon":"footprints","aliases":[],"order":310,"status":"available","articleCount":2,"groupTitle":"Behavioral patterns","intro":"","servedLang":"en","primaryArticle":{"id":"6b08bd3f80884893657cca38","slug":"visitor","title":"Visitor: new operations without changing classes","summary":"The Visitor pattern through a menu: dishes, drinks and sets stay untouched, while pricing, an allergen report or an export are separate visitor objects. Double dispatch, a comparison with pattern matching and code in five languages.","servedLang":"en","availableLangs":["pl","en"],"topics":["visitor"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","visitor","double-dispatch","pattern-matching"],"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":16,"stats":{"views":3,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:14:07.178Z","updatedAt":"2026-11-27T13:07:35.516Z","challengeCount":1,"quizCount":0},"articles":[{"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":3,"primary":false,"mainTopic":{"slug":"composite","title":"Composite"}}}],"challenges":[{"id":"6b093dc291bd8fbaf2a0c8dc","slug":"pricing-formula-visitor","title":"Pricing formula visitor","summary":"A pricing formula tree and three operations on it – evaluation, printing and simplification – as visitors. A new operation leaves the node classes untouched.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"hard","topics":["visitor"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["visitor","double-dispatch","expression-tree","composite","behavioral"],"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:26.391Z"}],"resources":[{"id":"6b0857c63c96f2d34d0b48b7","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=45MgUX_ih0s","embedUrl":"https://www.youtube-nocookie.com/embed/45MgUX_ih0s","title":"The Visitor Pattern in Python (And Better Alternatives)","description":"💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. The Visitor pattern has a reputation for being complicated, but the problem it solves is actually quite simple: what happens when you keep adding new operations to the same set of objects? In this video, I use a…","author":"ArjanCodes","thumbnailUrl":"https://i.ytimg.com/vi/45MgUX_ih0s/hqdefault.jpg","durationSec":null,"lang":"en","topics":["visitor"],"techs":["python"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-10-23T15:00:28.000Z","popularity":70,"verifiedAt":"2026-11-26T10:54:42.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857bf3c96f2d34d0b42d3","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/visitor","embedUrl":null,"title":"Odwiedzający / Visitor","description":"Odwiedzający to behawioralny wzorzec projektowy pozwalający oddzielić algorytmy od obiektów na których pracują.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["visitor"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:14.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857b53c96f2d34d0b3977","type":"article","provider":"web","url":"https://www.lihaoyi.com/post/ZeroOverheadTreeProcessingwiththeVisitorPattern.html?a=1","embedUrl":null,"title":"Zero-Overhead Tree Processing with the Visitor Pattern","description":"","author":"lihaoyi.com","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2018-05-27T07:07:37.000Z","popularity":67,"verifiedAt":"2026-11-26T11:07:40.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857b53c96f2d34d0b39ba","type":"article","provider":"web","url":"https://www.haskellforall.com/2021/01/the-visitor-pattern-is-essentially-same.html","embedUrl":null,"title":"The visitor pattern is essentially the same thing as Church encoding","description":"The functional programming analog of an object-oriented design pattern","author":"haskellforall.com","thumbnailUrl":"https://haskellforall.com/2021/01/the-visitor-pattern-is-essentially-same/opengraph-image?133960dfd41055ac","durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns","functional-programming","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2021-02-04T09:45:48.000Z","popularity":65,"verifiedAt":"2026-11-26T11:07:40.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857bf3c96f2d34d0b4293","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/visitor","embedUrl":null,"title":"Visitor","description":"Visitor is a behavioral design pattern that lets you separate algorithms from the objects on which they operate.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:07.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857cc3c96f2d34d0b4cae","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=BSpbBQhbdMs","embedUrl":"https://www.youtube-nocookie.com/embed/BSpbBQhbdMs","title":"GopherCon 2025: Go with the (Work)Flow: AI-Driven Code Generation for Workflows - Samantha Coyle","description":"Discover how we leveraged AI to transform workflow diagrams into Dapr Workflow application code. This lightning talk will explore our implementation using an Intermediate Representation (IR) and graph visitor pattern to support AI-driven code generation, offering insights into building durable…","author":"Gopher Academy","thumbnailUrl":"https://i.ytimg.com/vi/BSpbBQhbdMs/hqdefault.jpg","durationSec":null,"lang":"en","topics":["visitor"],"techs":["go"],"tags":["system-design","cloud","ai","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2025-12-11T03:01:31.000Z","popularity":40,"verifiedAt":"2026-11-26T10:57:05.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:15.892Z","updatedAt":"2026-11-26T16:01:15.892Z"},{"id":"6b0857bc3c96f2d34d0b4047","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/design-patterns-iterators-observers-and-chains-oh-my/id769189585?i=1000378375263","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id769189585?i=1000378375263","title":"Design Patterns – Iterators, Observers, and Chains, Oh My","description":"We’re back to the gang of four, continuing with another segment of design patterns. This time we’re talking about some of our favorite Behavioral Design Patterns: Observer, Chain of Responsibilities, Iterator patterns. Also, why the visitor pattern is weird and what it’s like to be raked over hot…","author":"Coding Blocks","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/f0/b6/68/f0b6682f-e8bc-181c-95a9-0756ddf63d6e/mza_3128980961332034780.jpg/600x600bb.jpg","durationSec":3828,"lang":"en","topics":["iterator","visitor"],"techs":["general"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2014-11-09T01:53:47.000Z","popularity":44,"verifiedAt":"2026-11-26T10:57:23.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}],"resourceGroups":[{"type":"video","items":[{"id":"6b0857c63c96f2d34d0b48b7","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=45MgUX_ih0s","embedUrl":"https://www.youtube-nocookie.com/embed/45MgUX_ih0s","title":"The Visitor Pattern in Python (And Better Alternatives)","description":"💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. The Visitor pattern has a reputation for being complicated, but the problem it solves is actually quite simple: what happens when you keep adding new operations to the same set of objects? In this video, I use a…","author":"ArjanCodes","thumbnailUrl":"https://i.ytimg.com/vi/45MgUX_ih0s/hqdefault.jpg","durationSec":null,"lang":"en","topics":["visitor"],"techs":["python"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-10-23T15:00:28.000Z","popularity":70,"verifiedAt":"2026-11-26T10:54:42.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857cc3c96f2d34d0b4cae","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=BSpbBQhbdMs","embedUrl":"https://www.youtube-nocookie.com/embed/BSpbBQhbdMs","title":"GopherCon 2025: Go with the (Work)Flow: AI-Driven Code Generation for Workflows - Samantha Coyle","description":"Discover how we leveraged AI to transform workflow diagrams into Dapr Workflow application code. This lightning talk will explore our implementation using an Intermediate Representation (IR) and graph visitor pattern to support AI-driven code generation, offering insights into building durable…","author":"Gopher Academy","thumbnailUrl":"https://i.ytimg.com/vi/BSpbBQhbdMs/hqdefault.jpg","durationSec":null,"lang":"en","topics":["visitor"],"techs":["go"],"tags":["system-design","cloud","ai","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2025-12-11T03:01:31.000Z","popularity":40,"verifiedAt":"2026-11-26T10:57:05.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:15.892Z","updatedAt":"2026-11-26T16:01:15.892Z"}]},{"type":"podcast","items":[{"id":"6b0857bc3c96f2d34d0b4047","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/design-patterns-iterators-observers-and-chains-oh-my/id769189585?i=1000378375263","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id769189585?i=1000378375263","title":"Design Patterns – Iterators, Observers, and Chains, Oh My","description":"We’re back to the gang of four, continuing with another segment of design patterns. This time we’re talking about some of our favorite Behavioral Design Patterns: Observer, Chain of Responsibilities, Iterator patterns. Also, why the visitor pattern is weird and what it’s like to be raked over hot…","author":"Coding Blocks","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts113/v4/f0/b6/68/f0b6682f-e8bc-181c-95a9-0756ddf63d6e/mza_3128980961332034780.jpg/600x600bb.jpg","durationSec":3828,"lang":"en","topics":["iterator","visitor"],"techs":["general"],"tags":["podcast","design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2014-11-09T01:53:47.000Z","popularity":44,"verifiedAt":"2026-11-26T10:57:23.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"}]},{"type":"article","items":[{"id":"6b0857bf3c96f2d34d0b42d3","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/visitor","embedUrl":null,"title":"Odwiedzający / Visitor","description":"Odwiedzający to behawioralny wzorzec projektowy pozwalający oddzielić algorytmy od obiektów na których pracują.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["visitor"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:14.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857b53c96f2d34d0b3977","type":"article","provider":"web","url":"https://www.lihaoyi.com/post/ZeroOverheadTreeProcessingwiththeVisitorPattern.html?a=1","embedUrl":null,"title":"Zero-Overhead Tree Processing with the Visitor Pattern","description":"","author":"lihaoyi.com","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2018-05-27T07:07:37.000Z","popularity":67,"verifiedAt":"2026-11-26T11:07:40.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857b53c96f2d34d0b39ba","type":"article","provider":"web","url":"https://www.haskellforall.com/2021/01/the-visitor-pattern-is-essentially-same.html","embedUrl":null,"title":"The visitor pattern is essentially the same thing as Church encoding","description":"The functional programming analog of an object-oriented design pattern","author":"haskellforall.com","thumbnailUrl":"https://haskellforall.com/2021/01/the-visitor-pattern-is-essentially-same/opengraph-image?133960dfd41055ac","durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns","functional-programming","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2021-02-04T09:45:48.000Z","popularity":65,"verifiedAt":"2026-11-26T11:07:40.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857bf3c96f2d34d0b4293","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/visitor","embedUrl":null,"title":"Visitor","description":"Visitor is a behavioral design pattern that lets you separate algorithms from the objects on which they operate.","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["visitor"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:07.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}]}],"siblings":[{"slug":"chain-of-responsibility","title":"Chain of Responsibility","icon":"link","status":"available","current":false},{"slug":"command","title":"Command","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":"Memento","icon":"save","status":"available","current":false},{"slug":"observer","title":"Observer","icon":"eye","status":"available","current":false},{"slug":"state","title":"State","icon":"toggle-right","status":"available","current":false},{"slug":"strategy","title":"Strategy","icon":"route","status":"available","current":false},{"slug":"template-method","title":"Template Method","icon":"layout-template","status":"available","current":false},{"slug":"visitor","title":"Visitor","icon":"footprints","status":"available","current":true}]}