Today I’ll be going through the Strategy Design Pattern. However, before we go in-depth, let's start off with a scenario that may seem all too common to some of us (especially when we become lazy with our code).

What if we wanted to create an application to perform some sort of calculation? Well we could create a method to handle the calculations! But these calculations could vary depending on the choice of the user or the input of the function. How should we handle it? Should we do something like this?

// Assuming only 1 of the inputs are true


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store