Do You Follow a Recipe?

28 Apr 2022

The “Recipes” of Coding

What is the first thought that comes to mind when you hear the topic “Design Patterns”? Before taking this class the only design patters I ever heard about were dealing with arts or graphics. So, I automatically assumed it was how to make websites pretty, giving it an aesthetic look. Boy, was I wrong… Design patters are more like a template that can be used for most situations when you change it up to fit your specific situation. They are used to give you a generalized solution to problems that commonly occur. These templates were put together by programmers to make future generations coding experience more bearable.

Why Baking?

Typically you will know I am having a bad day or stressed out because I will be in the kitchen baking. I love to bake to decompress because it allows me to bring out my creative side. During the pandemic I was baking cookies, cakes, breads, etc. As we are learning about design patterns the first thought that comes to mind is how I am able to relate it to my different baking recipes. How does it relate you may ask? Well, the recipe that you are given is a general template on how you can make something, it is your choice if you want to follow it or put your own twist to it. You already know what you are wanting to make, the look you are going for, and what you want it to taste like. The recipe is just giving you an idea on how much of the main ingredients you can be adding. For example, if you are wanting to bake brownies, you the main ingredients you will be needing are flour, eggs, coco powder, sugar. After that is it up to the baker if you want to add additional ingredients to give it a unique taste. That is just like design patterns. You are given a template where you can reuse it and change it to fit your problem you are trying to solve. Design patters are used as a tool to better your code, not to have your work done for you by other people.

Are You Still Talking About Food?

After learning about design patterns I started to notice how I was implanting them into my codes without even knowing it. The current project I am working on with my team is implementing a website called Manoa Eats . Yes, ironically we are working on a website about food and I am relating design patters to baking. There are aspects within our website that have implemented design patters.

Observer Design Pattern

Within our website we are using this several times. One of the times we are using this is when the user creates a profile. We have them enter their information into a form and once they submit that form they are prompted with a notification and their information will be stored with the rest of the profiles.

Singleton Design Pattern

In our “I’m Feeling Hungry” page this design pattern is being used. We are using the Restaurant.jsx component to randomly list one restaurant as a card on the page.