{"slug":"iterator","group":"behavioral","title":"Iterator","short":"Walks through a collection without exposing how it is stored.","icon":"list-ordered","aliases":[],"order":303,"status":"available","articleCount":2,"groupTitle":"Behavioral patterns","intro":"","servedLang":"en","primaryArticle":{"id":"6b08bd3980884893657cc996","slug":"iterator","title":"Iterator: walking a collection without looking inside","summary":"The Iterator pattern through orders from a delivery app fetched page by page: the loop in the report knows nothing about pagination, and pages load lazily, only when needed. Generators, yield and iter.Seq in five languages.","servedLang":"en","availableLangs":["pl","en"],"topics":["iterator"],"techs":["dotnet","typescript","java","go","python"],"tags":["gof","behavioral","iterator","generators","lazy-evaluation","pagination"],"level":"beginner","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:14:01.513Z","updatedAt":"2026-11-27T13:12:16.793Z","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":2,"primary":false,"mainTopic":{"slug":"composite","title":"Composite"}}}],"challenges":[{"id":"6b093dc191bd8fbaf2a0c8d4","slug":"paged-results-iterator","title":"Lazy iterator over a paged API","summary":"Orders from an API that returns pages with a cursor, exposed as one collection – lazy page fetching, skipping empty pages, protection against a looping cursor and the native iteration protocol of every language.","servedLang":"en","availableLangs":["pl","en"],"kind":"code","category":"pattern","status":"published","difficulty":"medium","topics":["iterator"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["iterator","pagination","lazy-evaluation","generators","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:25.658Z"}],"resources":[{"id":"6b0857bf3c96f2d34d0b42c8","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/iterator","embedUrl":null,"title":"Iterator / Iterator","description":"Iterator to behawioralny wzorzec projektowy, pozwalający sekwencyjnie przechodzić od elementu do elementu jakiegoś zbioru bez konieczności eksponowania jego formy (lista, stos, drzewo, itp.).","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["iterator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:12.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"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"},{"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":"6b0857be3c96f2d34d0b4203","type":"article","provider":"web","url":"https://martinfowler.com/articles/collection-pipeline","embedUrl":null,"title":"Collection Pipeline","description":"Collection pipelines are a programming pattern where you organize computation as a sequence of operations which compose by taking a collection as output of one and feeding it into the next.","author":"Martin Fowler","thumbnailUrl":"https://martinfowler.com/articles/collection-pipeline/collection-pipeline/sketch.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["martin-fowler"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:07:27.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857bf3c96f2d34d0b4279","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/iterator","embedUrl":null,"title":"Iterator","description":"Iterator is a behavioral design pattern that lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["iterator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:04.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}],"resourceGroups":[{"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":"6b0857bf3c96f2d34d0b42c8","type":"article","provider":"web","url":"https://refactoring.guru/pl/design-patterns/iterator","embedUrl":null,"title":"Iterator / Iterator","description":"Iterator to behawioralny wzorzec projektowy, pozwalający sekwencyjnie przechodzić od elementu do elementu jakiegoś zbioru bez konieczności eksponowania jego formy (lista, stos, drzewo, itp.).","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/pl/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"pl","topics":["iterator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:12.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857be3c96f2d34d0b4203","type":"article","provider":"web","url":"https://martinfowler.com/articles/collection-pipeline","embedUrl":null,"title":"Collection Pipeline","description":"Collection pipelines are a programming pattern where you organize computation as a sequence of operations which compose by taking a collection as output of one and feeding it into the next.","author":"Martin Fowler","thumbnailUrl":"https://martinfowler.com/articles/collection-pipeline/collection-pipeline/sketch.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["martin-fowler"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:07:27.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857bf3c96f2d34d0b4279","type":"article","provider":"web","url":"https://refactoring.guru/design-patterns/iterator","embedUrl":null,"title":"Iterator","description":"Iterator is a behavioral design pattern that lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).","author":"Refactoring.Guru","thumbnailUrl":"https://refactoring.guru/images/refactoring/social/facebook-share-preview.png?id=dbf9e98269595be86eb668f365be6868","durationSec":null,"lang":"en","topics":["iterator"],"techs":["general"],"tags":["design-patterns"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:26:04.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":"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":true},{"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":false}]}