Design Pattern Explained
2015-07-09 04:13
471 查看
The Command Pattern:
encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations
public interface Command { public void execute(); } public class LightOnCommand implements Command { Light light; public LightOnCommand(Light light) { this.light = light; } public void execute() { light.on(); } } public class RemoteControl { Command slot; public RemoteControl() {} public void setCommand(Command slot) { this.slot = slot; } public void buttonPressed() { slot.execute(); } }
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
相关文章推荐
- leetcode 70:Climbing Stairs
- Design Pattern Explained 读书笔记二——设计模式序言
- 解决adb not responding you can wait more
- Climbing Stairs
- 凸优化:ADMM(Alternating Direction Method of Multipliers)交替方向乘子算法系列之五: Constrained Convex Optimization
- leetcode 011 —— Container With Most Water
- cache_peer和cache_peer_domain详解
- 四 错误处理篇 How to Fix Login Failed For User NT AUTHORITY IUSRS in SharePoint 2013 ...
- Codeforces 240E. Road Repairs 最小树形图+输出路径
- Climbing Stairs
- Dynamics AX 2012 R2 配置E-Mail模板
- No valid signing identities (i.e. certificate and private key pair) matching
- adb logcat时提示waiting for device
- 人工智能来了 有人或因此失业 有人将如虎添翼
- Dynamics AX 2012 R2 设置E-Mail
- Flask-Mail邮件的配置以及发送附件的方法
- 人工智能领域中声源定位的研究与发展------第三章 展望
- [leetcode][hash] Contains Duplicate III
- ASE 登录 报错Msg 4002, Level 14, State 1:Login failed. CT-LIBRARY error: ct_connect(): protocol speci
- Dynamics AX 2012 R2 AIF自定义服务中的事务回滚Bug