The Daily WTF
The Strategy Pattern, like any other design pattern, is supposed to help us write code that’s flexible and easy to modify. In the case of the strategy pattern, you have one class, the Context, which has a member which implements a Strategy interface. The actual implementation lives in the Strategy, but the Context is the object that other code in the program consumes. Ideally, this means that you can change the behavior of your Context by simply swapping a different Strategy implementation in.
On the flip side, when it gets out of hand, you might end up like Dotan, consuming an API from a major cloud vendor, written with a terminal case of “Pattern Brain”.
$backoff = $config->get(Options::BACKOFF); if ($backoff === null) { $backoff = new BackoffPlugin( // Retry failed requests up to 3 times if it is determined that the request can be retried new TruncatedBackoffStrategy(3, // Retry failed
To read the full article click on the 'post' link at the top.