One important criterion is whether polymorphism will create a relationship that this strategy could avoid. For example, if you implement the “save ()” method for a class tree, which means using low-level I / O functions, then if you use polymorphism, the class tree will be bound to the I / O system, whereas it wasn’t “t until. However, if you use a strategy template, the strategy objects will serve as a “buffer” and save the class tree depending on the I / O.
source
share