25.Strategy(行为型模式)
来源:互联网 发布:铜陵网络台袁晋明 编辑:程序博客网 时间:2024/06/10 07:49
【起源】
某个对象的行为,可以用多种算法实现,因此考虑将算法单独封装出来(利于算法维护),在创建对象时再指定具体算法。
【动机】
定义一系列算法,把它们一个个封装起来,并且使它们可相互替换。该模式使得算法可独立于使用它的客户而变化。
【核心】
对象组合的使用。
与Bridge模式很像,但Bridge关注的是“由谁来实现”;Strategy关注的是“用哪种方式实现”;
使用时,首先提炼会变化的算法,抽象出接口;然后将具体算法实现单独封装,实现接口;最后在类中组合该接口;
【代码实例】
【模型图】
- 25.Strategy(行为型模式)
- 行为型模式-----策略模式(Strategy)
- Strategy模式(策略模式 行为型)
- 策略模式Strategy(对象行为型)
- 设计模式--行为型-Strategy(策略)
- 策略模式 Strategy (行为型)
- 策略模式Strategy(对象行为型)
- 策略模式Strategy(对象行为型)
- 策略模式Strategy(对象行为型)
- 策略模式Strategy(对象行为型)
- 策略模式Strategy(对象行为型)
- 行为型-策略模式(strategy)
- strategy-对象行为型模式
- 行为型模式-策略(strategy)
- 行为模式:Strategy(策略)
- 设计模式(十三)策略模式(Strategy)-行为型
- 设计模式(4)-行为型-策略模式(Strategy)
- 设计模式 ( 十八 ) 策略模式Strategy(对象行为型)
- Android中的sp和wp指针 (转)
- ORACLE 中ROWNUM用法总结! (转)
- c语言实现正序链表的创建(不使用头结点)
- 编译不能生成obj文件
- 一般用户的root操作
- 25.Strategy(行为型模式)
- 2010工作总结
- Flex 中鼠标进出框体的事件
- linux文件共享方式
- 页面计数器对同一登录用户的处理
- org.apache.commons.lang.StringUtils
- Ajax技术实现的购物车,使用Cookie保存。
- 去掉android的屏幕上的title bar
- 预处理宏定义