Before I went back to school to get another degree, this time in computer science, I taught people how to kiteboard. This sport begins with an immensely steep learning curve that quickly plateaus as newbies gain proficiency in the basic concepts and are able to put the pieces together coherently. In other words, kiteboarding has many moving parts, literally. The kite is moving while you sit in the moving ocean as you are blown down wind while you try to get your board on your feet. Then you have to fly the kite to generate force to pull you up out of the water while you try to balance on a board. I used to tell my students, kiteboarding lessons are expensive, (often $150 per hour or more), and you will probably need about 8 hours, but after those 8 hours, you will be able to set up your kite, launch your kite, ride back and forth safely, self-rescue when things go wrong, and land your kite on the beach when you are finished. However, there is an alternative. You can go off and try to figure it out on your own. It can take people a year to learn on their own what I could teach them in a few hours. There are things that they will never know they would want to learn until the situation came up. For instance, there are times when setting your lines up down wind from your kite is superior to up-wind. The kite will behave differently when the wind is on-shore, cross-shore, side-shore, or off-shore, so how to do launch and land in these various conditions. I can show them various equipment setups for different styles of riding. If they want to ride wake-style, we use wakeboard boots on a twin tip, but sometimes a surf board first the conditions better. These are the design patterns of kiteboarding and by following them, one can avoid the struggles of trial and error faced by those who go it alone. Software engineering design patterns serve the same purpose. While there are many approaches to solving any one problem in computer science, there are certain techniques that will be more effective than others. Taking a tried and true approach can be particularly useful when starting out, because solving a complicated programming problem can be just like learning to kiteboard on your own.
I realized as I was writing the first paragraph that it could come across as if I was saying that I have always taken advantage of design patterns while coding, unfortunately, this is not the case. Before returning to college for this degree, I spent a lot of time teaching myself how to code. While I had never heard of design patterns, I understood that I was missing something in my programming education. I could get my code to work most of the time, but I knew it was poorly organized, and this flaw was at the heart of my decision to get a formal education. Still, I have written a lot of code since coming to this school, and it is not until now that I have been formally introduced to the concept of design patterns. Yet, I have used them often. I built a user interface that detects changes in augmented reality markers, and when I first wrote the code, the data went everywhere and nowhere at the same time, and I had some serious performance issues. My solution to this issue led to the first time that I implemented a publisher/subscriber design pattern. I thought about how the human brain takes input from the different parts of the body, interprets this input, then sends out the necessary data to areas that need to react to this input. Everything flows through the brain to streamline the process. Publisher/subscriber does the same thing. All data is processed in a central location then sent out to whatever objects or functions need to be notified of a state change. The singleton pattern has also been useful for me, although I always felt that it was sort of the lazy way out. I created an object for my interface that held some of the global state variables that could be accessed and changed easily. I will soon be refactoring my entire program once again, and when I do this, I plan to avoid this pattern. I think that I will be able to better control the flow of information in my code without the need for global access to any variables. I believe that a well-designed publisher/subscriber pattern is far superior to a singleton pattern.
Ultimately, I am just getting started with design pattern and look forward to utilizing them in my code as I grow as a developer. I came to college so that I could make my learning process more efficient and I believe that design patterns are key to that goal.