[Special] Design Pattern - Behavioral Patterns - Command Pattern

来源:互联网 发布:java搜索引擎lucene 编辑:程序博客网 时间:2024/05/19 02:24

2007

Section 2, Chapter 3


Command Pattern


Concept




Use

This is useful in the case of undoing or redoing some action, or simply storing an action in a request queue on an object.



Design

The Command pattern has three main components:

  • the Invoker: acts as a link between the commands and the receiver and houses the receiver and the individual commands as they are sent;
  • the Command: an object that encapsulates a request to the receiver;
  • the Receiver: the component that is acted upon by each request.




Illustration




0 0