Did You Realize! The Often-Unknown World of Design Patterns

28 Nov 2018

What In The World is a Design Pattern?

Design patterns? What are those? Maybe that was your first reaction to this term. It certainly was mine! Perhaps you have no idea what they are, or maybe you do. Either way, I’m going to give you my perspective on it and explain what I’ve learned from using it. Hopefully, it’ll give you a new perspective and deepen your interest.

The Definition…Simplified

So, what’s the actual definition of a design pattern? Well, boiled down, it is a general solution to a commonly occurring issue in software design which can be repeated. Basically, it isn’t a refined solution, rather it’s like a formula for finding solutions. You could think of it as a rule-of-thumb or “the way that rookies get to benefit from the experience of the masters”, to paraphrase my software engineering professor, Philip Johnson.

Similarities

To help you gain a clearer understanding of this concept, consider a simple math formula or rule, such as the chain-rule which is regularly used in Calculus. Without it, finding the derivative of complicated functions would be much more difficult. Another good example might be the Pythagorean theorem. If you know the Pythagorean theorem, you can find Pythagorean identities and solve for variables. Design patterns are similar, but not quite the same. However, the result is similar to the way we use formulas in math. By using a design pattern in software engineering, you can solve problems more easily and more efficiently.

The Big Reason

On your own, it would have taken a long time to figure out a math formula on your own (unless you’re some kind of math genius and aren’t constrained by the challenges facing the average human), but by using the formulas that the great mathematicians developed you can find solutions easily. The same concept goes for design patterns. Now, once you did into them, design patterns can get complex. There are a lot of different patterns in use, and I definitely don’t understand all of them.

How Do You Use ‘Em?

So, what does using design patterns entail? Well, if you’re in the computer science field, and if you haven’t heard about it before, you’ve probably been using design patterns for a long time without knowing! I was actually surprised to find that it was something I had been doing without realizing it. In my software engineering experience, I’ve used the Prototype, Observer, Model-View-Controller, and Front Controller patterns, just to name a few.

The Details

Now I understand all those pattern names are a bit confusing, and I won’t go too deeply into them, but to give you some understanding, I’ll examine some of them. The Prototype pattern, used in Javascript, enables you to create objects by copying other instances. This is different than the standard Object Oriented structure used in languages like Java and C++. Another one is the Observer pattern, which is seen in Meteor via the Reactive Data aspect. In Meteor, this enables code in a MongoDB collection (the database) to be re-run if the collection is updated. Both of these make it much easier to engineer software and along with a load of other patterns enable you and me to code with much less difficulty and frustration.

Making Sense of the Patterns

So, what’s the whole point? Well, first off, using design patterns will (and probably already does) make your life a LOT easier. Second, since you’re already using design patterns, it’s probably worthwhile to learn a bit about them and become a better computer scientist in the process. Finally, they enable you to achieve a better understanding of the software engineering process and will enable you to do your work in a more capable and understanding way. Give it some effort - dig in to design patterns and discover the often-unknown world that awaits!