java几个设计模式之间的区别

Q1: What is the difference between State and Strategy patterns? {#Q1}

状态模式和策略模式之间有什么区别

While the implementation is similar they solve different problems. The State
pattern deals with what state an object is in - it encapsulates state-dependent
behavior.
The Strategy pattern deals with how an object performs a certain task - it
encapsulates an algorithm.

虽然这两种设计模式实现非常类似,但是他们解决了不同的问题,状态模式处理对象所处的状态,封装了依赖于状态的行为,
策略模式处理对象如何执行特定的任务,它封装的是算法

Q2: What is the difference between Strategy and Template Method patterns? {#Q2}

策略模式和模板方法模式的区别

In Template Method the algorithm is chosen at compile time via inheritance.
With Strategy pattern the algorithm is chosen at runtime via

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值