Iterator (cursor)

This pattern suggests providing an approach to sequentially access the elements of an aggregate object and, at the same time, hide the underlying implementations.

The preceding diagram depicts the structure of the iteration pattern in which the iterator interface defines traversing methods, and the concrete iterator implements the interface. Aggregate defines an interface for creating an iterator object, while a Concrete aggregate implements the aggregate interface to create an object.

Here are the benefits:

  • It supports variations in the aggregate traversals
  • Iterators simplify the aggregate interfaces
  • It may have null iterators and helps handle boundary conditions better
  • Impacts
  • It may introduce additional maintenance cost (dynamic allocation of polymorphic iterators)
  • It may have privileged access and thus introduces complexities to define new traversal methods in iterators
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset