Head First Design Patterns

 

1.The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.----Head first design patterns

策略模式定义了一族算法,并将每一个都进行封装使他们变得通用。策略允许这些算法独立于使用他们的客户端自由变化。

2.The Observer Patter defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.[观察者模式定义了一个一对多的依赖关系,当对象的状态发生改变时,所有依赖于他的观察者都会被通知并自动更新状态].

常见的运用了观察这模式的例子就好比为按钮设置一个监听器,按钮作为主体对象,监听器listener作为观察者,当按钮发生状态改变,比如被单击时,相应的click listerner就会被触发。

 

 

 

你可能感兴趣的:(design pattern)