It is a good idea to use the iterator pattern whenever you want one or several of the following behaviors:
Make it easy to navigate through a collection
Get the next object in the collection at any point
Stop when you are done traversing through the collection
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.