Grokking Design Patterns for Engineers and Managers
Vote

0% completed

Iterator Pattern

The Iterator Pattern walks a collection without exposing how it stores its items.

Client code needs to visit every element. If it walks by index, it now depends on the collection being an array. Change to a linked list, a tree, or a paged remote source, and every loop that touched it breaks.

There is a second problem, and it is the larger one. Some sources have no index at all. A tree can be walked depth first or breadth first. A graph needs a set of visited nodes. A search API returns two results at a time and knows nothing about the sixty you eventually want

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content