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.

By

Updated

Cheat sheet: Iterator: Next Stop, Please
Category
Data Structures
Level
Journeyman
Tags
Code Smell, encapsulation, Iterator Pattern, OOP