concept

composition

The characteristics of

Application scenarios

  1. Multiple classes differ only in their behavior, so you can use the Strategy pattern to dynamically select the specific behavior to be performed at run time.

    implementation

  2. Different policies (algorithms) need to be used in different situations, or policies may be implemented in other ways in the future.
  3. The implementation details of specific policies (algorithms) are hidden from the customer, completely independent of each other

The advantages and disadvantages

implementation