Significance of Design Patterns

23 Apr 2019

Design Patterns in life

Imagine you are having one of those days where you are just sick. You are laying in bed and do not have any energy to do anything. What is the one thing that comes to mind after that? For me, it is the idea of getting better. What do people normally do to get better? They take some sort of medicine, whether it be your mother’s home remedy, prescription medicine, or any other kind. Medicine is normally the solution for getting sick and that is exactly what a design pattern is. A design pattern is a solution that is repeated for a common problem. Based on what I was saying, medicine is the general solution for the common problem of getting sick. Medicine is a solution that can be repeated over and over again but yet it still works in solving the problem of someone being sick.

My experience with Design Patterns

The most prominent experience that I have had with a design pattern is the observer design pattern. The “reactivity” in Meteor is a good example of this design pattern. What happens is that once you update a reactive variable in your code or you update a collection in MongoDB, the code will be re-run and react based on what you just updated. Meteor observes what changes you have made and based on that it updates accordingly. This is again comparable to medicine. Updating a variable or a collection can be compared to taking our medicine since medicine “updates” the condition of your body and sickness. When the code is re-run and it reacts based on what was updated, that is similar to someone taking a rest and having the body react to the medicine. Once the body reacts to the medicine, it will “update” the condition of someone in order to reflect the medicine that was taken. Overall, design patterns are very useful in software engineering and they help to solve common problems with the same approach, just like medicine solves the sickness problem.