December 2016
Beginner to intermediate
238 pages
6h 10m
English
© Kelt Dockins 2017
Kelt Dockins, Design Patterns in PHP and Laravel, 10.1007/978-1-4842-2451-9_24
Kelt Dockins1
(1)Dolph, Arkansas, USA
$> git checkout strategyDefine a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.1
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 ...
Read now
Unlock full access