Iterator pattern
It allows traversal through a list or collection of data using a standard
interface without having to know the details of the internal representations of that data
Iterator interface
It declares the operations required for traversing a collection
Concrete iterators
They implement specific algorithms for traversing a collection
Collection interface
It declares one or multiple methods for getting iterators compatible with the collection
Concrete collections
They return new instances of a particular concrete iterator class
Client for the iterator pattern
It works with both collections and iterators via their interfaces
When to use the iterator pattern
Mediator pattern
It is a mechanism for facilitating communication between components
Concrete Mediators
They keep references to all components they manage
Mediator interface
It declares methods of communication with components, which usually include just a single Notify or Send method.
Components
They are one or more classes that contain some business logic
When to use the mediator pattern
Memento pattern
It allows saving and restoring the previous state of an object without
revealing the details of its implementation
When to use the memento pattern
The Memento pattern lets you make full copies of an object’s state, including private fields, and store them separately from the object.
The Memento makes the object itself responsible for creating a snapshot of its state
Originator class
It can produce snapshots of its own state as well as restore its state from snapshots when needed
A caretaker
It keeps track of the originator’s history by storing a stack of mementos
The memento
It is a value object that acts as a snapshot of the originator’s state.