For Every Design: A Pattern

25 Apr 2024

When you start seeing a pattern…

Imagine you’re writing up some code for a program one fine day. You’ve finished a segment and are about to move on to the next when you notice your IDE showing signs of errors in your codes somewhere. Directing your attention to the lines highlighted by the IDE, you take a quick scan and realize that the issue is pretty simple. No worries! Just apply a nifty design pattern and poof! Now it’s resolved without having to put as much work into it as you had writing up your code. Throughout my programming times, I’ve encountered multiple issues that were simple in nature but took me a decent chunk of my time fixing since I solved them one at a time in a unique fashion. Regrettably, this method persisted for a long while, until earlier this year, when I learned of design patterns.

A pattern, designed for the problem at hand

Design patterns were interesting to learn about. They aren’t functions or libraries you can just download and plug in for an easy one-and-done fix, but rather guidelines for identifying and solving common problems whereever they’re found. Think of them as a specialized help section tailored for coders to reference in their work-to-work day. These design patterns help to expedite bugfixing by providing a structure for fixing a problem in a small amount of time with minimal effort rather than force the coder to divert unnecessary brainpower towards identifying and fixing the problem. While the idea and execution of design patterns did take a good bit of time to understand and utilize, I definitely see the benefits of implementing design patterns in my everyday coding.

Finding the right pattern for the right design

I’ll admit, my implementation of design patterns has not been smooth. Far too often do I find myself back to simply brainstorming my way through these simple problems when they should not have required as much as I used. This was brought upon by me falling back into those old habits since I’ve gotten so used to doing so that I usually autopilot my way into said effort. However, my best implementation of design patterns has to do with my final project that I’m working on alongside a team, where I had used a Controller design pattern for rendering the deletion of certain objects in the database. This helped immensely as before, the code that I had come up with threw a lot of errors and didn’t properly de-populate the database when used.

Patterns for the future

Design patterns have been not just helpful but also interesting. They offer a way to tackle commonly-encountered problems without expending much effort in solving them in a satisfactory manner. I can definitely see myself using them a lot more as my career advances.