design pattern notes [7] - state,strategy,memento,mediator,and iterator
2012-12-24 20:50
423 查看
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.
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.
相关文章推荐
- design pattern notes [7] - state,strategy,memento,mediator,and iterator
- the difference between state and strategy design pattern
- State Design Pattern: Ultimate Hook
- head first Design Pattern State
- design pattern notes [4] - chain of responsibility, visitor
- 设计模式学习—备忘录模式(Memento Design Pattern)
- State Design Pattern: Reminder
- State Design Pattern 状态设计模式
- design pattern notes [4] - chain of responsibility, visitor
- State Design Pattern
- Learning OpenCV Lecture 2 (Using the Strategy pattern in algorithm design)
- Asp.net Design Pattern study notes -- PART 2
- head first design pattern -Strategy
- 状态模式在领域驱动设计中的使用(Using the State pattern in a Domain Driven Design)
- 状态模式(State Design Pattern)
- 设计模式学习—策略模式(Strategy Design Pattern)
- 《Head First Design Patterns》笔记一:策略模式(Strategy Pattern)
- State Design Pattern 状态设计模式2
- design pattern notes [6] - Observer
- design pattern notes [8] - interpreter, and command