设计模式金玉良言<一>

  • 策略模式的本质:少用继承,多用组合。
  • STRATEGY PATTERN DEFINITION: it defines a family of algorithms(算法?),encapsulate each one, and makes then interchangeable. strategy lets the algorithm vary independently from clients that use it.(策略模式是定义一组能够不断更变的algorithms, 把它们封装起来。)
  • Identify the aspects of your application that vary and separate them from what stays the same.in other words, take the parts that vary and encapsulate them, so that later you can alter or extend the parts that vary without affecting those that don't.(确定应用程序中会变的和不变的因素, 把会变的部分封装成单独的组件。这是设计模式的本质所在。)
  • SimUDuck(Strategy Pattern) Big Picturethe big picture on encapsulate behaviors
  • favor composition over inheritance(相对于继承,要善于用组合。)
  • OBSERVER PATTERN DEFINITION: it defines a one-to-many relationship between a set of objects so that when one object changes state, all of it's dependents are notified and updated automatically.(观察者模式是定义了这样一种1对多的关系,当subject改变状态的时候,其他所有的observers都会被通知同时改变状态。)
  • Observer Pattern Big Picturethe big picture of observer pattern
  •  When two object can interact, but they have very little knowledge of each other, then we call they are loosely coupled, as the observer pattern.(当两个对象能够相互作用,但它们对对方知道的都特别少,这时候我们就说它们是松耦合的。观察者模式就是这样的,subject和observer是松耦合的。)
  • Java build-in Observer Pattern Big Picturejava build-in observer pattern big picture
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值