Design Patterns 101

28 Apr 2022

Design Patterns for Dummies

When it comes to design patterns in software engineering they go beyond the syntax of a certain language or a class/library you can simply import, it concerns the architecture of the code you are writing giving it structure. A simple definition for a design pattern is a general repeatable solution that a programmer can implement with their code to solve a commonly occurring problem in software design. After doing some quick research I found that there are many, many, many different types of design patterns software engineers have came up with to combat their developing woes and improve structure, here are the three basic kinds of design patterns:

Knowing this why should we use design patterns? The answer is simple, it makes life as a programmer much easier especially if you are working together with a team. Design patterns are tried and tested solutions to the common problems we encounter in software design, and also work to prevent certain future problems occurring. With plenty of documentation of these different patterns and their uses it can become common knowledge amongst your team members and allow communication of proposed solutions more efficiently between each other by mentioning these said patterns. Another helpful aspect of design patterns is that it improves code readability and simplifies organization which helps developers and programmers alike think about their code in a broader perspective and understand how the individual cogs would work in unison.

Looking Back

In my early journey as a budding programmer and aspiring software engineer I have used some of these design patterns without even knowing it. From what I remember I have used a Singleton class before to create a class representing the sky, where the Singleton pattern ensures that there would only be one instance of the sky which is realistic! These singleton classes are similar to global variables where you access this instance from anywhere in the program. Thinking back on it I have used many of the creational patterns such as the Factory method when using superclasses, Abstract Factory method using abstract classes, and what we have been using the Prototype pattern all semester on GitHub through cloning of repositories onto our local computers. These are all excellent concepts that when put into practice made the process of object creation much easier by reusing code that was already written. Some behavioral patterns I remember encountering are the Iterator pattern when I used iterators to iterate over various data structures, and with Semantic UI I wanted to implement a Modal and this required using the State pattern since the Modal had different internal state changes. I feel as if I am just at the tip of the design pattern iceberg and I can’t wait to grasp an even better understanding of them! Seeing as I am a novice when it comes to design patterns I felt like the resources I used below were super helpful, especially refactoring.guru which I suggest checking out if you want to learn even more in depth.

Sources for info: sourcemaking.com, refactoring.guru