$> git checkout strategy
Intent
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.1
Applications
The strategy pattern is useful when you have algorithms that share the same public interface but work differently under the hood. The strategy pattern generally relies on composition to pass in the varying algorithms. The Laravel encryption 2component uses the same methods to encrypt and decrypt messages. The underlying cipher algorithm can change, though. This is a loose implementation of the strategy ...