GoF-Iterator Pattern

Details
Full Name

GoF Iterator Pattern (Behavioral)

Intent:

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

When to Use:

  • When you need to access an aggregate object’s contents without exposing its internal representation

  • When you want to support multiple traversals of aggregate objects

  • When you want to provide a uniform interface for traversing different aggregate structures

Prompt Example:

"Implementiere einen Iterator nach GoF für die benutzerdefinierte Baumstruktur, der verschiedene Traversierungsstrategien (Tiefe, Breite) unterstützt."