行为型模式
Software Architecture & Engineering · 10 notes
- Template Methodhistorical
When an algorithm's overall steps are fixed but details vary, the template method keeps the process in a parent class and delegates variable parts to concrete implementations.
- State Patternhistorical
The state pattern chooses behavior according to an object's current state. These notes compare it with the strategy pattern through examples.
- Strategy Patternhistorical
When a task has several possible approaches, the strategy pattern separates the algorithms and selects an appropriate strategy.
- Observer Patternhistorical
The observer pattern notifies observers when a target object's state changes. These notes introduce the notification relationship through those two roles.
- Chain of Responsibilityhistorical
A chain of responsibility links handlers for a type of request and passes requests along the chain. These notes illustrate it through scenarios such as Servlet filters.
- Mediator Patternhistorical
Direct interactions among objects can create complex coupling. The mediator pattern places coordination in an intermediary, illustrated here through examples.
- Command Patternhistorical
Examples involving courses and command interfaces demonstrate the command pattern and how requests are wrapped as objects for execution.
- Memento Patternhistorical
The memento pattern stores an object's state for later restoration. These notes examine saving and retrieving state through scenarios such as undo.
- Visitor Patternhistorical
The visitor pattern separates data structures from operations into different classes. These notes use code to examine how operations act on the structure.
- Iterator Patternhistorical
Iterators provide a way to traverse aggregate objects separately from their structure. These notes record the pattern and its use in the JDK.