In the programming sphere "Design Pattern" by Gamma, Helm, Johnson and Vlissides is a true classic. The book from 1995 set a standard, shaped the language we use in the software engineering domain and is used in innumerable university courses. This article is my attempt to critique it on multiple levels while avoiding to sound like a know it all prick. Not an easy task, since the criticism will be harsh.
But to start with the good: the main idea is very powerful and uplifting. Yes, there are reoccurring patterns in class structures that aim to solve reoccurring challenges. And it is helpful to identify, name and analyze them in order to express concisely how our program is constructed and to know something beforehand about the up- and downsides of our design choices. Being a massive proponent of that made me write these lines.
However, as stated in the foreword and chapter 6.3 of the conclusion part, this great idea came from Christopher Alexander, an architect of buildings. He was mainly interested in architecture that supports human flourishing - something not mentioned in chapter 6.3. In order to serve the inhabitants, he expected also that design patterns were mixed and adapted freely. A stark contrast to the cooky cutter approach of our four suspects.
Their primary goal, as stated in the introduction, was to simplify the design and reuse of object oriented (OO) software. OO programming was just entering the main stream and our gang tried to facilitate that by using The main stream language for OO at the time (C++) in their examples. They did apply all the powerful OO features C++ had to offer, while ignoring the much simpler reuse by composition or argument (post about that is incoming). In short - they chose inheritance as their hammer and every problem became a nail. And as a result, some solutions are unnecessary complicated. Another big chunk of bloat could be removed by using OO features popularized after the book was published. Although, that doesn't stop people to teach the original pattern even today. And this might be the biggest mistake - to perceive these patterns as sacrosanct. The gang members spread this attitude by teaching to replicate the pattern in our own code over and over. But the natural and sane tendency of programmers is to remove boiler plate and to ensure that staples of daily life become part of the core language or at least the standard library, so that they can be accessed through an expressive syntax and with the least amount of typing. (I got that insight from Mark Jason Dominus.) These patterns should show up in the way a program functions, but not necessarily in its written form.
In summary: I miss the intellectual rigour in this book. Some patterns mix several ideas, some are repeating previous ideas and some are not pattern at all, but mere examples tied to unnecessary specifics. This confusion can only result in overcomplicated class structures that drain life force out of the programmer who mentally lives in them. That form of gangsterism is the opposite of what Christopher Alexander longed for.
Top comments (0)