The Startup
Published in

The Startup

Understanding the Strategy Pattern

Sometimes, we end up writing a class with a huge amount of methods that all look annoyingly similar, but there are key differences in the way they calculate things that keep us from writing one generalized function and throwing out the rest. Today, we’re going to take a look at a design pattern that allows us to create that one function to rule them all so that we can scrap those annoying almost-duplicate methods. Enter The Strategy Pattern.

Photo by Lauren Mancke on Unsplash

--

--

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