<<< Observer Sample, cont. | Index | Visitor, cont. >>> |
Problem to solve: consider mixed hierarchy of nodes representing a messy(*) three-dimensional scene in a graphics application.
(*)The nodes represent many unrelated classes, with no common parent class.
How could we uniformly examine the nodes?
We might try an Iterator pattern, which separates the algorithm from a collection of objects.
However,
Iterators traverse objects only in homogeneous containers.
Iterators don't work with elements of unrelated data types.
To invoke operations via an iterator, the objects must derive from a common parent class.
Other iterator and container type-specific restrictions may exist.
<<< Observer Sample, cont. | Index | Visitor, cont. >>> |