Designing Like Ninjas

01 May 2018

On my first day of second grade, my teacher comes in and sits at her desk. She immediately starts stomping and clapping in sequence. She continues to do this for about five minutes until the confused students have to ask why she continues these motions. Here is a summarized version of her response: “Patterns are an essential part of life. No matter where you look, or what you are doing, there will be some kind of pattern around you.” Over ten years later, as I sit and think about my numerous experiences, I have realized that she was right. I have also realized patterns aren’t necessarily just a repeated sequence. Patterns are meant to be reused and incorporated, so that life can become easier. This is the concept of a Design Pattern: A repeatable solution or template to a commonly occuring problem in software design. Upon learning design patterns, my professor put a very good conceptual metaphor to them. “Patterns help newbies acquire the hard-won experience of ninjas.” (Dr. Philip Johnson) Design patterns allow beginning programmers to have greater control and flow to their code like “ninjas”.

A ninja, defined by many sources, is a not just a master of ninjitsu, they are a master in a certain skill or activity. Like a ninja, a beginner programmer’s greatest tool are design patterns! Design patterns aren’t just implementations to creatively maneuver around common problems, but rather come as a guide to solving problems. Beginner programmers are often first taught the back-end side of programming: the initial skills and building of an application. Most times, they aren’t just thrown under the bus either. They are given sample templates and code to base theirs off of. Only after a couple of years of experience are programmers introduced to the front-end, user interface side of programming. Design patterns allow the user to find the connection between the front-end and back-end of programs.

Design patterns are very commonly found in the code that I and others write. There are some extremely common patterns that I use almost every time I write code. The prototype design pattern is always implemented when using inheritance. Creating objects off of a superclass comes up a lot when writing in Javascript. Also, programmers rarely want the front-end side of programming to change an instance in the back-side of the application, so private class data is also used a lot when coding. Currently, I am in the process of creating a web application that allows users to update the status of washing machines in their university dorms. The Model-View-Controller (MVC) design pattern is a key part of this application. The application is backed by a Mongo DB database to hold the washers, which serves as the model. The application is designed using the React Semantic UI Framework, which the user sees, so it is considered the view. The Controller is the React Router, which is controlled by the users which changes the status of the washers in the database (model). Therefore, while I am still a beginner programmer, implementing these design patterns has not only given me control over my application, but lets the application run very smoothly, allowing me to feel like a programming ninja.