State allows the object alter its behavior when its internal state changes. This pattern avoids large, multipart conditional statements. It also introduces more classes.
The transition between states is implemented in the subclasses of State.
I think strategy is like visitor. Review it!
The memento does not break encapsulation. It stores snapshot of internal states of an Originator so that the Originator can restore its previous state when a caretaker lets it do that. The caretaker does not know how the memento save Originator's state. It just requests the Originator to store states to or restore states from the memento respectively. The memento simplifies the Originator although sometimes it is expensive.
Mediator encapsulates how a set of objects interact. It promotes loose coupling by keeping objects from referring to each other explicitly. It is amazing to find that c++ begins to behave like that most of c source codes do.
It centralizes CONTROL!
Iterator provides a way to access an aggregate object sequentially without exposing its underlying representation.
阅读(1115) | 评论(0) | 转发(0) |