1
JavaAdvanced#design-patterns
A behavioral pattern that defines a family of interchangeable algorithms, encapsulated behind a common interface, allowing the algorithm to be selected at runtime without modifying the client code.
interface DiscountStrategy { double apply(double price); }
class BlackFridayDiscount implements DiscountStrategy { public double apply(double p) { return p * 0.5; } }
double finalPrice = strategy.apply(100.0);