How do we know what we know today? Is it magic? Did we just happen to know everything from the start? The answer to that, is no. The reason that we know many things these days is because of the trial and error of the people that came before us. Their efforts have guided us through a solution template of how we think and work. These solutions are called design patterns. With design patterns, we are able to avoid the frustrating work of figuring out complex algorithms or patterns.
As a student studying Computer Engineering, I’ve used many design patterns throughout my entire college career. For starters, I use the singleton design pattern to assign global variables to act as state definers in Arduino. This could be something as simple as a state to determine if a LED should be on or off or act as a counter to assign different states in a system. This semester in ICS314, we focused a lot of JavaScript early on. JavaScript uses the prototype design pattern when creating objects and using them in multiple instances. In this sense, I’ve been using the prototype design pattern unknowingly yet who can argue that’s a bad thing.
Lastly, loading the entire weight of the semester with just one design pattern is the Model-View Controller. All of our efforts in this course over the entire semester has lead up to this point to where we create our final projects using the Meteor API to deploy our web application. Under Meteor, we use the MongoDB as our model, React as our view, and the React Router as our controller. We have also used the singleton design pattern using meteor for our final project. We have a class called Profile
which manages the MongoDB collection Profile
.
So why do we use design patterns? To put it simply, it simplifies our work. Why take the hard and difficult road when there’s an easy and simplified one paved for us? Using design patterns can enable us to find better solutions that the ones we were using. Once those solutions are found, we can share it so that the knowledge is passed on to others like a torch.