C语言设计模式:命令模式 //tbd

本文介绍命令模式的基本概念,包括如何将请求封装成对象以便参数化客户端、实现请求的队列和记录功能,以及如何支持撤销操作。文章还讨论了命令模式中的四个核心组件:命令、接收者、调用者和客户端。

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

Four terms always associated with the command pattern are commandreceiverinvoker and client. A concrete command object has a receiver object and invokes a method of the receiver in a way that is specific to that receiver's class. The receiver then does the work. A concrete command object is separately passed to an invoker object, which invokes the command, and optionally does bookkeeping about the command execution. Any concrete command object can be passed to the same invoker object. Both an invoker object and several concrete command objects are held by a client object. The client contains the decision making about which commands to execute at which points. To execute a command, it passes the command object to the invoker object. 


将方法(请求)定义为对象,这些对象即为命令。支持命令的排队、记录以及undo功能。

代码:TBD


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值