定义:The strategy pattern defines a family of algorithm, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
一句话:action不是object里面hardcode的一部分而是一个object instance,所以action可以runtime换成你需要的。
类比:跟赛车游戏里面给汽车换零件的道理一样:同一个功能不同的实现,需要的时候换一个。
一句话:action不是object里面hardcode的一部分而是一个object instance,所以action可以runtime换成你需要的。
类比:跟赛车游戏里面给汽车换零件的道理一样:同一个功能不同的实现,需要的时候换一个。