The Iterator Pattern

dead-metaphor TravelObject-Oriented Design

Categories: software-engineering

What It Brings

An iterator, etymologically, is “one who goes” (Latin iter, journey). The word once evoked a traveler moving through a landscape, visiting each location in turn. The GoF Iterator pattern maps this onto collection traversal: an iterator moves through a data structure, visiting each element without exposing the structure’s internals. Today, most developers use iterators without thinking about journeys at all — the metaphor has fossilized.

Key structural parallels (when the metaphor was alive):

Where It Breaks

The Iterator pattern’s metaphor broke long before most developers encountered it. The word “iterator” has become a pure technical term, as divorced from its Latin roots as “computer” is from “one who computes.” But examining the original metaphor reveals its limits:

The real evidence of metaphor death: developers now use “iterate” as a transitive verb meaning “process sequentially” (“iterate the array”) with no sense that anyone is traveling anywhere. The word has been fully absorbed into technical vocabulary.

Expressions

These expressions persist, but few developers consciously invoke the journey metaphor:

Origin Story

Iteration as a concept predates the GoF pattern. The word entered computing through FORTRAN’s DO loops and COBOL’s PERFORM statements in the 1950s, already technical. The object-oriented Iterator pattern crystallized in Smalltalk’s collection classes, which provided do: blocks for traversal. By the time Gamma et al. formalized the pattern in 1994, “iterator” was standard vocabulary. The metaphorical origin in journeys and travelers had been dead for decades. The GoF book doesn’t even explain the etymology — it treats “iterator” as a self-evident technical term, which by then it was.

References

Related Mappings