Iterator Design Pattern (UML Diagrams)
Resources|Diagrams|Design Patterns| 3 July 2020 | Dusan Rodina - softwareideas.net
The Iteration design pattern describes how to iterate a collection so that the iteration algorithm is decoupled from the collection class.
The iterator pattern allows you to define various traversing algorithms for a collection. You may define a forward and backward iteration of a list, breadth-first and depth-first iteration of a tree, etc. The collection is represented by the Aggregate role and the traversing algorithm is defined by the Iterator role.
Design Pattern Parts
The iterator design pattern defines these roles:
- Iterator - traversing algorithm
- Concrete Iterator
- Aggregate - collection of objects
- Concrete Aggregate
Iterator Pattern in Diagrams
The iterator design pattern structure depicted in UML class diagram and the behavior shown in UML sequence diagram.
Iterator Design Pattern (UML Class Diagram)