A Reflection on Design Patterns

09 May 2018

Over the course of the past few years, programming tasks in school were handled in a certain way. In the core computer science classes at UH Manoa, there is a pattern in the way that C, C++, and Java are taught to students. Students are taught to handle certain types in a specific way. But, as a student, what one doesn’t realize, is that the way we are taught to handle these tasks are formally referred to as “Design Patterns”.

By definition, design patterns are known ways in which various tasks can be solved, a technique, if you will. These patterns can be applied to a myriad of different scenarios, and will lead to some form of a solution. This does not necessarily mean that the chosen pattern is the absolute right one to use. Similar to working in retail, there is a multitude of ways in which a sale can be closed, but it doesn’t mean that the technique used was the best. For example, using cost as a way to sell ink for a luxury writing instrument may lead to closing the sale, but suggesting a case to accompany the writing instrument, or other new products from the same brand could have led to closing a higher sale, increased product moved and numbers for the specific brand, as well as a better commission for the sales associate. Similarly in coding, a factory method may seem great for an object-oriented program. But for a small, beginner level program that only has one object, maybe a singleton pattern would be better.

Looking back on the time spent learning languages such as C and Java, object-oriented programming was fairly emphasized in their respective courses. Now, it can be realized that some of the homeworks in these courses implemented design patterns. For instance, when learning Java, event handlers were used, and served as an implementation of the Observer design pattern. There were also times where the Factory design pattern was used, which helped to illustrate creating instances of various objects in a certain language. Prior to the Factory design pattern, the Singleton was indirectly taught when first experiencing instances of objects on a small scale.

All in all, design patterns, though not always obvious, have been indirectly taught to computer science students throughout certain coursework. Also, it not just something that can be applied to strictly programming, but as explained before, the concept of patterns can be seen in other disciplines as well. Finally having dived into some of the history and details of design patterns has clarified a lot of personal experiences over the years of being a computer science student.