The 18 pattern is best used whenever there's a need to traverse a data structure and access its elements.
You may wonder why you would need this battery instead of a loop to traverse a collection.
Well, the good thing about this battle is that it does not expose the underlying structure of the container
that is being traversed.
The iterators decouples the data from the algorithm used for traversing a container.
A very good example of an iterator is the Java dot dot iterator interface from the Java API.
Looking at the UML diagram for this pattern, you can see that we have two abstractions for the container
that will be traversed and for the iterator, the employee director class will implement the container
and it will be based on the list containing the names of the employees of a company.
When they enter, their class will implement the iterator and it will contain the algorithm for its
overseeing the employees container.
Let's see how this can be implemented in the code.