How behavior and communication are distributed among objects. The lecture covers Iterator and Observer in detail and names the rest of the family for recognition.
Covered in detail: Iterator and Observer. The rest are named so you recognize them as behavioral.
createIterator()hasNext() and next()attach(), detach(), notifyAll()update()update() and registers itselfupdate()update() in every observer| Iterator | Observer | |
|---|---|---|
| Solves | Walking a collection without knowing how it stores elements | Many objects reacting the moment one object's state changes |
| Relationship | One client to one traversal at a time | One Subject to many Observers |
| Cue phrase | "access the elements sequentially without exposing the representation" | "one-to-many dependency, notified automatically" |
| Where they meet | The Subject iterates its observer list inside notifyAllObservers() |
| Category | Concerned with | This course's patterns |
|---|---|---|
| Creational | How objects get created | Abstract Factory, Factory Method, Singleton, Builder, Prototype |
| Structural | How classes and objects are composed into larger structures | Adapter, Composite, Facade |
| Behavioral | How behavior and communication are distributed | Iterator, Observer |