Comparing Strategy and State
The refactored code consists almost entirely of simple methods in simple classes. This is an advantage in its own right and makes adding new strategies easy. The refactoring relies primarily on the idea of distributing an operation across a related group of classes. In this regard, STRATEGY is identical to STATE. In fact, many developers wonder whether these are really different patterns.
On the one hand, in the real world, strategies (such as recommending a firework) and states (such as a carousel door with a one-touch control button) are clearly different ideas. This real difference leads to different problems in modeling states and strategies. For example, transitions are important when modeling states but usually irrelevant when choosing a strategy. Another difference is that STRATEGY might allow a client to select or to provide a strategy, an idea that rarely applies to STATE. On the other hand, the differences in modeling states and strategies may seem subtle. Certainly, the reliance on polymorphism makes STATE and STRATEGY appear almost identical structurally. Either way, if you decide that these are or are not two separate patterns, you will be in good company.
be in good company: 有很多人相伴,大有人在