The essence of the Iterator Factory method Pattern is
to "Provide a way to access the elements of an aggregate object
sequentially without exposing its underlying representation."
This pattern is used to get a way to access the
elements of a collection object in sequential manner without any need to know
its underlying representation.
We should have a mechanism to traverse in the same way
a list or an array. It doesn't matter how they are internally represented.
Important Points
- Iterator pattern is useful when you want to provide a standard way to iterate over a collection and hide the implementation logic from client program.
- The logic for iteration is embedded in the collection itself and it helps client program to iterate over them easily.
- Applicability & Examples
The iterator pattern allow us to:
- access contents of a collection without exposing its internal structure.
- support multiple simultaneous traversals of a collection.
- provide a uniform interface for traversing different collection.
No comments:
Post a Comment