Gang of Four: Desing Patterns
Feb 01, 2015
Last week I finished an older book Design Patterns by GoF. It’s one of the bibles of SW development and I had never read it so it was time to fix that. Plus the interview with GoF on Software Engineering Radio #215 was very interesting.
My notes are a little sparse because I borrowed the book from library and already had to return it. Luckily, there’s a nice overview of the book on Wikipedia. The borrowed book was in Czech and tried really hard to translate everything including the names of all the patterns. It reminded me of my university courses when the lecturers insisted on using the strange Czech names of the patterns with an explanation that it’s easier for beginners. It’s not, it’s just confusing. The translator and publisher had enough insight to at least keep the English terms in subtitles and parenthesis to anchor them.
The book created a prototype for documenting design patterns and is pretty straightforward. It opens with a motivation, continues with a shallow but extensive example of a text editor and then dives into the catalogue of patterns themselves. It consists of three groups: creational, structural and behavioural patterns. The complete list is on the Wikipedia.
I have to admit I mostly didn’t read the code samples. They are written in C++ or Smalltalk and even though I would get through the code I settled for the description of the pattern with its implications which were generally the most interesting part of each pattern.
Nice thing about reading the book is that I have some experience and I was able to appreciate the patterns better than during the first semester when everything was way too abstract. I have actively used some of the patterns in my day to day work and sometimes I even knew I was doing that! Generally the patterns aren’t anything magical or surprising. They’re just a distillation of a lot of effort put forth by programmers over the years trying to solve problems as best as possible. Generally, anyone would come to them facing the same problem and having time to think about it, albeit probably not realizing all the implications. There lies the greatest benefit of the book. Plus having names for things. (Which doesn’t prevent flames about a single pattern. Apparently there’s Singleton - the good kind but other Singletons are anti-patterns, Dependency Injection is a hot topic etc.)
What the aforementioned Wikipedia page about design patterns made me realize is the long list of concurrency patterns which I’ll have to read up on. I rarely have to deal with concurrency in my code and have only a very superficial understanding of it supplemented by a label Dangerous: Enter only if you want your head to explode. However, I believe the list of patterns and three episodes of SE Radio will be helpful.Share