Baking the Perfect Cake

15 Apr 2024

I cracked my first egg in elementary school to bake a cake. While that may not be surprising, since I imagine that many of us have, it actually took me quite a long time to consistently crack eggs without having the shells fall into the yolk. It’s a minor accomplishment, but I was rather proud of it. Being a newbie at baking (and cooking at the time), my basic preparation skills were awful to say the least. Thankfully, to make up for my slow whisking or egg cracking, I had the powerful tool of an online recipe. With this, the cakes I pulled fresh out of the oven, ended up looking like cake! Awe inspired, I started looking up different cakes—sponge cakes, cheesecake, carrot cake, and even lava cakes.

The Recipe

There are countless cakes, varying heights of tiers, themes for birthdays or weddings, and cakes with different styles of frosting. These cakes are unique, with recipes that are individual to them. Yet, cakes still follow a general pattern. Prep the batter, pop it in the oven, and dress it up. Depending on the specific type of cake, you can make minor adjustments to the recipe. Likewise, software engineering has design patterns, the same way cakes have a general pattern. Design patterns in software engineering are the “recipe” to the cake. Based on your needs, you can use these different design patterns. This includes design patterns such as the Factory, Singleton, Observer, and Model-View-Controller design patterns. Much like actual cake, there are specific parts of the webpage that you may be “craving,” as each design pattern has its own respective pros and cons. Perhaps your design includes many dependent objects so you’d have a Factory design pattern focus, or a global “state” with a Singleton design pattern focus. Of course, you’d still have to be aware that some could be harder to debug than others or generally more complicated. There are also “antipatterns” that one should take care to avoid. Put simply, they are patterns that you do NOT want as your solution. After all, you do not want to mistakenly add a cup of salt to the batter when it is supposed to be a cup of sugar. One such example is “lava flow,” leaving previous design information from past implementations just taking up space, solidifying into a troublesome stone taking a while to remove. One recommended way to prevent this issue is by clarifying your code and regularly testing it. Which recipe you use and the approach all depends on your needs and cravings.

Putting it in the Oven

Recently, I personally have been baking my own cake using the Model-View-Controller (MVC) design pattern. As the name suggests, it has a focus on three fundamental components of the design pattern: the model, the view, and the controller. The view hides the raw information and data (the model), making it look appealing and understandable to use the controller, which is how the user would interact with the information. As this cake of mine is also being baked with a team, the MVC design pattern has the added benefit of being incredibly easy to divide the work between each other. The ease of splitting responsibilities is especially apparent to me, as I am experiencing MVC firsthand with a team. It’s almost as though we are working on different tiers of a cake separately, and in the end, stacking them all on top of each other to make a singular stunning cake. However, the MVC design pattern naturally has its own steep learning curve, but fortunately my team and I have experience in parts of its implementation, which led to a smooth baking process. The cake my team is currently baking is a project called Mānoa Rainbow Cards, and it uses mongodb as the model, .jsx components and pages as the view, and buttons and input fields as the controller.

Enjoying a Slice

Perhaps I am biased, but creating things, whether it be a literal three-tier cake or a webpage with a beautifully simple user interface, is something that I will always enjoy. I will likely encounter antipatterns in my code at some point, but I’d like to think that experience will improve my ability to produce better results. There is just something about all the puzzle pieces coming together and fitting all in the right spots. Even now, while currently baking a cake, I intend to bake even more, using all the recipes I can to make a better, perhaps even perfect, cake.