Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
I have a surprise for you. (I hope it’s a good one.) You already know the first of the design patterns we’re going to be exploring.
When we were examining DEPENDENCY INVERSION in the last chapter, we saw that it’s often implemented by a technique called “programming to interfaces”, which looks like this:
That’s the basic structure of the STRATEGY PATTERN. There is one little twist, though: The pattern is technically only the STRATEGY when it represents some behavior of the ClientClass (not just an object the ClientClass works with.)