# Iterator: Next Stop, Please

When every piece of code that walks a route has its own loop over how the route is stored, changing the storage breaks all of them; an iterator hands out the stops one at a time, so callers ask for the next stop and never learn whether it came from a list, zones or a server.

![Cheat sheet: Iterator: Next Stop, Please](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/5b208c6808bd47738f9cc863edcb8d8a.webp)

- Category: Data Structures
- Level: Journeyman
- Tags: Code Smell, encapsulation, Iterator Pattern, OOP
- Author: Gregor Dzierzon
- Updated: November 17, 2026

Source: https://www.ask-codey.com/cheat-sheets/dp-iterator-cheat-sheet
