Design Patterns as Pizza

03 Dec 2020

Before you are confused any further by the title, yes food and software engineering do not exactly have a whole lot in common. However, if you are like me and you appreciate tangible visualizations when studying more abstract concepts (which you often encounter in computer science) food can be a very helpful tool in understanding design patterns. Design patterns in software are defined as general solutions to a commonly recurring problem. These general solutions should not be thought of as a final product but rather as a template to be modified to meet the nuances of the specific problem. So where does pizza come into play?

Not only is pizza one of my favorite foods, but it also happens to be a great example of a design pattern. What is the recurring problem? Well, the problem here is hunger and the general solution is pizza. While a plain cheese pizza could be just what the stomach ordered, it might not always satisfy every person’s specific hunger. What if someone is hungry but they also want some sort of meat? A pizza can easily be modified to accommodate this need by adding pepperoni or sausages as toppings. What if someone wants some vegetables? We could easily add mushrooms, spinach, or tomatoes to the pizza. Toppings represent the modifications that software developers can add to shape their final product in response to different requirements.

In my introduction to design patterns I worked with a simple Meteor React application template. This template worked primarily with React uniforms to update and display data stored in collections. This template was an effective demonstration of how you can use design patterns to create a variety of applications with the same core function. For example we were able to transform this basic template into an address book application as well as a dashboard for displaying human profiles.

The moral of the story is if a concept is ever a little challenging to visualize, try to imagine it in terms of something that you can picture. Design patterns are pizza.