One solution, Infinite Use.

28 Apr 2022

Understanding Design Pattern

Haven’t you ever seen the term design patterns in programming? What are design patterns, and how are you used in your code? These questions commonly pop out during interviews, and if you don’t know anything about it, you are in trouble. Yes, I am in trouble. When I first saw the term design patterns, I thought about the patterns of pages you design. Like a menu at the top, several functions at the body, and a footer at the bottom of the page. Those repeat designs. But, that is not really what design patterns are. Design patterns are something way more than that. By Christopher Alexander, design patterns “describe a problem that occurs over and over again in our environment and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice”(1977). To me, it means design patterns are a pattern of solutions that we could use to solve a problem that can appear in many different scenarios when you are programming. Basically, it means a re-useable form of solutions.

Design Pattern in Real World

What is your favorite restaurant in town? What caused you to go there? The food? The atmosphere? Or the friendly workers. How often do you go there? You have tried many restaurants in town, and nothing can beat your favorite dish at your favorite restaurant. The experienced chef and their specific technique make it unique. What can you do if you want to eat your dish every day? There are days the restaurant closes and run out of the ingredients for your favorite dish. What can you do if you want it so bad? You might want to ask for the recipes. That chef takes the time and effort to develop the recipes that could repeatedly use to cook the dish. You can cook it by yourself at home, with the recipes and the specific technique you had learned from that chef to satisfy your taste buds. Design patterns are solutions or recipes you used to solve general solutions to problems you faced. They are the solutions software developers have tried repeatedly to develop a pattern of solutions you could use. Like a chef, develop a recipe that we could cook the same food a million times and taste the same.

Unnoticed Use of Design Pattern

As Professor Johnson said in the video, we use those design patterns without noticing them. After I think back and look at my previous assignments, I use design patterns a lot (original templates). For example, in the final project, we had in ICS 314. The name of the project is walking with pele, and the purpose of the project is to provide places and activities for our UHM students to enjoy, relax and study. Those activities and places will have special offers for UHM students only. We will provide default places and activities that the user could choose, and the user could add more to it. A transfer of data changes the objects of our project of activities or places on our list page. Also, we had a like bottom for users to click on depending on the number of likes. There is a page that displays the top three likes spot. This is an example of observer design patterns. An object maintains a list of its dependent and notifies them automatically of any state changes. There are more design patterns out there, and having a basic understanding of them is a wise step to make your life easier.