What is the Strategy design pattern?

Answer

The Strategy pattern defines a family of algorithms, encapsulates each one in a separate class, and makes them interchangeable. The context object holds a reference to a strategy interface and delegates the algorithm to whichever concrete strategy is currently set. For example, a payment processor can use a CreditCardStrategy, PayPalStrategy, or CryptoStrategy interchangeably — the context (checkout) doesn't need to know which one is active. This eliminates conditional logic for choosing algorithms and makes it trivial to add new strategies. Java's Comparator is a well-known implementation of this pattern.