Design patterns exist naturally in the world. It exists in math–an absolute truth in the universe; it exists in the way that bees gather honey for their beehives. We, as humans, replicate what we see in nature through our creations. We see it with food, communities, architecture, and art.
Recently, I’ve been watching a show called “Rhythm + Flow” on Netflix depicting a rap competition show, featuring Cardi B, T.I., and Chance the Rapper as the judges. Great show, you have to watch it, especially if you’re into the hip-hop culture or competition shows in general.
While I was watching it, I noticed that there’s a design pattern in the makings of rap, too. Something as structural as programming does not sound like it would have any commonalities with something as free-spirited as rap, but humans create things that they see in nature. In any rap, song, or artwork, there are methods and styles used to make it. There’s the verse, the hook, the catchy beat, and so forth. There’s always a specific way to write a verse; many of these rappers write a verse with thoughts of what they want to say in their story. Next is the hook; they write the hook like they’re writing a summary of their message in a catchy way. All artists have different styles of incorporating themselves into their music, but this is the “design pattern” that they default to. There are methods of doing things based on different circumstances, and that’s basically what design patterns do. They give generalized solutions to help a programmer produce code in the most efficient method possible just like how they help rappers write their raps and songs in the most marketable way possible.
Now, I’m not a rapper. I would say I’m an elementary artist, but like these rappers, I implement design patterns into my work as well, and that includes my coding. Hindsight, I remember using design patterns for object-oriented classes in my introductory computer science course, where we created a game that had a variety of objects with similar functions. I didn’t know that they were design patterns until now that I’m reading up on it. These similar functions came from one idea of a core pattern in which each object had the same function, something that I learned now is called “prototype.” Our game consisted of obstacles that would shoot out or “rain” down randomly on the screen, which the player had to avoid. Utilizing the prototype design pattern helped us to efficiently have one base class for all these obstacles and subclasses to follow the basic implementation of the base class while also having its own individualistic features. This saved us a lot more time and space than we thought, and the game ran perfectly with no problems.
Design patterns are everywhere. They give us the template to figure out problems in the least complicated and effective way possible. Who wouldn’t want to use design patterns? Even rappers use them, too.