| Introduction to OOP | Chapter 24: Design Patterns : | next | previous | audio | real | text |
Solution: Allow clients to manipulate an object that can return the current value and move to the next element in the collection.
Example, Enumerators in Java
interface Enumerator {
public boolean hasMoreElements();
public Object nextElement();
}
Enumeator e = ...;
while (e.hasMoreElements) {
Object val = e.nextElement();
...
}
The pattern applies, even if the interface is changed.