Knowing Is Half The Battle

30 Nov 2021

What a design pattern feels like

Upon being taught about design patterns, I felt as if a light finally turned on in my head. Even after only seriously learning how to code for 2-3 years, I felt as if many of the problems that I worked on had something to do with other problems I have dealt with in the past. It wasn’t just simply a matter of reapplying the same formula, but following a recipe you used before with different ingredients each time. That is what using a design pattern feels like to me. Design patterns are essentially structured ideas that provide a possible solution to common software problems.

From a game to a website

With the Singleton pattern, I don’t think I could even count the amount of times I may have used this strategy in some of my other classes. One example off the top of my head would be how I created a Player class in a game engine, which was a singular instance of a private class that interacted with other elements in my game. Another example is how we use MongoDB collections in this class. Each collection is represented as a single class instance and is called throughout the application. It just goes to show how flexible design patterns really are when you apply them. Another pattern that I have used in my previous work is the decorator pattern, where I created a base class for a weapon, and created different weapons classes based off the normal weapon class that had special magical properties.

Will I continue to use design patterns?

I don’t think I even need to answer that question. Design patterns show up in various aspects of life, even outside of software engineering. You just have to be creative and experienced enough to apply them.