“[Design patterns] describe a problem that occurs over and over again in our environment,, and then describes the core solution to that problem, in such a way you can use this solution a million times over, without ever doing it the same way twice.”
Christopher Alexander
Design patterns are general, reusable solutions to a commonly occurring problem in software design. It is a template that can be used in many different solutions. As Dr. Johnson stated “patterns help newbies acquire the hard-won experience of ninjas.” This sounds familiar…. This almost sounds like something we’ve been doing all along. Not just in our class, but in all aspects of life. After all, when problems arise in our life, do we not attempt to solve or approach the situation based on our or even others’ past experiences?
When I say that we use it in all aspects of life, I mean we use it in ALL aspects of life. For example, cooking! An even more specific example, my go-to recipes. I’m a lazy cook. I am not great at it and I do not have the time nor patience to prepare something too complicated. In the mornings, I usually like to eat protein oatmeal. Obviously it involves protein powder and oatmeal, but I don’t make it the same every day. Sometimes I’ll customize it with different toppings, but the staple ingredients include protein and oatmeal. I love making foods like that, foods that don’t require much thinking and that you can throw together very easily, but it’s never the same each time. Another cooking example would be ground beef/meat. You can make so many things with ground beef; Korean beef lettuce wraps, hamburgers, loco moco, etc. The way to initially prepare the meat is the same, but it results in different things.
If not cooking, then how about when you ask your friend for advice on a problem that they may have had before? You take their words and experience into consideration when attempting to solve your version of the problem. Surely there are more real-world examples, but I’m sure you know what I mean. What I guess I’m trying to say is, design patterns are like templates.
Okay, let’s try to narrow it down. Design patterns can be compared to when we, computer science students, search stackoverflow for a general solution to our problem. Obviously we don’t copy the exact code, or maybe we do… that is what all the memes about being a programmer are like…(am I gonna get in trouble?) Anyways, we don’t copy the exact code, we modify it to fit whatever assignment or task we’re trying to accomplish. The code we copied serves as a template to our solution. Narrowing it down even further, the templates we use in class! With each WOD and with our final projects, we are building it off of the templates introduced to us in class (i.e. the meteor-react template). When we narrow that down even further, the meteor-react-template is an example of MVC.
“When implementing a user interface, it is desirable to decouple the internal representation of information from the way it is presented to and accepted from the user.”
The model is like the database, the view would be the presentation (the HTML and CSS portion of the code), and the controller decides what is presented to the viewer and how. Basically, that is what the meteor-react-templates do, and what we’ve been doing for our WODs and projects.
That is just one of the many different types of design patterns. Design patterns are just templates/guidelines of solutions to recurring problems, and if you really think about it, anything you do solve a problem or accomplish a task could be compared to a design pattern. You’ve probably been using one for something in your life without even thinking much about it.