Skip to content

Latest commit

 

History

History
8 lines (6 loc) · 447 Bytes

File metadata and controls

8 lines (6 loc) · 447 Bytes

Introduction

Defines a family of algorithms, encapsulates each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients who use it.

介绍

策略模式定义了算法家族,分别封装起来,让他们之间可以相互替换,此模式让算法的变化不会影响到使用算法的客户

本例解析

  • 通过context对不同的策略进行封装,减小算法的改变对客户端的影响