用通俗的话理解设计模式-Command pattern
来源:互联网 发布:黑暗之魂3白色头发数据 编辑:程序博客网 时间:2024/05/22 06:31
Given this situation, the way to create a new and much powerful functionality maybe impossible to avoid the two following steps:
first, to utilize the existing code or method in other classes
second, in order to use other classess' method, you have to create loads of corresponding class instance.
however, if the utlized class has modified some code, what you have to do is to modify your code to make the utlized class compatible and make the maintence. This issue is typically named as your class is coupled with the utlized classes.
what'more, if the number of the classes you have reused is a large number. It would be complex to invoke your class.
The Command pattern can also trackle the above situation and get around the potential troubles.
Instead of instantiating a lot of classes, programming to the interface can make your class invokation be clear and clean. Your class can just invoke an execute() method. The implementation could be carried out by diverse varity of classes that has been done by others.
after making an interface for your class, the remaining job is to implement the execute() method.
the intent of the command pattern is encapusulating a request as an object. So it's inavoidable to create the utlized classes' instances since you have to invoke the method in these classes. maybe the method implementation is always a dirty and hard work that must be done.
- 用通俗的话理解设计模式-Command pattern
- 用通俗的话理解设计模式--Decorator pattern
- 用通俗的话理解设计模式-Template Method pattern
- 用通俗的话理解设计模式--Adapter pattern to Facade pattern
- 设计模式通俗理解
- c#设计模式-Command Pattern
- 命令设计模式(Command Pattern)
- 设计模式的通俗理解
- 设计模式的通俗理解
- 设计模式 - Command Pattern(命令模式)
- 设计模式 - Command Pattern(命令模式)
- 设计模式之命令模式(Command Pattern)
- 设计模式14 - 命令模式 Command Pattern
- c++设计模式:命令模式(Command Pattern)
- 设计模式 - 命令模式(command pattern) 详解
- 设计模式 - 命令模式(command pattern) 详解
- 设计模式心得:命令模式 (command pattern)
- 设计模式-命令模式(command pattern)
- U-Boot编译过程完全分析2-include/autoconf.mk和make all
- java response 下载文件
- mysql 乱码问题 linux
- hudson
- 使用float:left来实现横排的列表框
- 用通俗的话理解设计模式-Command pattern
- UVa 10827 - Maximum sum on a torus
- SpannableString对微博内容的处理(超链接、用户名、主题点击跳转)
- redis 命令行操作记录
- C# —— 使用C# NPOI 读取Excel(.xls)文件
- hdu 3535 分组背包
- 难道天要亡我么?
- MySQL内部临时表策略
- C++中的强制类型转换函数