I recently downloaded a cool fighter plane game (iFighter lite) on my iPhone. As I started playing, I felt that plane is
moving a bit slow!! But soon enough I saw a little perk on the screen and I flew over it and suddenly plane's speed increased. Soon enough, enemy planes started attacking me and I shot back at them. But again I felt my bullets were too slow! I shot down few planes and a new perk showed up on the screen. As soon as I collected it, my plane started shooting more bullets per attack!!
Yeeee hoo!!! I started enjoying this and before I knew, I by mistake collected a "skull and bones" perk and "darrnn!!" I said, cause I knew now my plane had lost those powerful bullets :(
Now, of course I am not writing a review about the human behavior while playing games on iPhone! But what I am trying to highlight here is the plane's ability to act differently in certain conditions! And that's something the Strategy Design Pattern allows us to do. I’ll try to use this game as an analogy to discuss about Strategy Design Pattern.
Definition: Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.