Okay, so a blog isn’t the ideal format to dump 7000 words worth of thoughts on the subject of a book that weighs half a kilo. 🙂
I used to write film reviews: each fortnight I’d knock out about ten 50 to 100 word reviews of movies on in the local area. I learnt a basic rule of criticism: it’s an awful lot easier to be nasty than nice. I’ve had the same challenge here: the better a pattern is, the harder I find to write about it. Lord knows I find it easy enough to write about Singletons.
The dry and formal style of the Gamma et al disguises this problem: it attempts to be even handed the entire time, so the question of emphasis is moot. Moreover, my opinion of what are the “best patterns” are, to a certain extent, coloured by my perception of which are “unobvious”. Thus, those that I find hardest to describe are exactly those I want to describe the most. (This isn’t strictly the case: I’d regard the visitor pattern as the hardest of the lot to describe.)
There’s also the difficulty that some of the patterns are so similar that they’ve generated an entire sub-industry discussing them. I wouldn’t worry about this too much: many patterns are useful only to the extent to which they clearly and succinctly describe a concept.
Table of Contents
Obviously, this being a blog, the structure of this changes with time. Bits get revised and expanded upon. This is a suggested reading order. Patterns in brackets are not class Gang of Four patterns
- Stone Cold Brilliant
- Substitution Patterns (essential)
- Annoying (but still essential)
- Useful terminology
- Pretty Special Case
- Unhelpful terminology/ Best Ignored
A note about the last category: you could say I’ve trashed a third of the book, but that’s not the case. What I’m saying is that modern practice has moved on:
- Iterator and Interpreter are pretty much built in these days
- Observer and Mediator are component of Publish/Subscribe
- Bridge / Template Method / Strategy are special cases of good practice.
- Flyweight, again, is basically just a special case of a more general piece of good practice.
So, they’re not terms I use (although Rx means I’ve got to dust off observable…) but that doesn’t mean the concepts are bad. The only true anti-patterns are Singleton and Prototype. (Memento isn’t that useful, but if you’re in its use case space and can’t achieve the same effect with an event driven design, it’s a good option.)
Beyond The Gang of Four
Here’s some patterns not listed that everyone should know:
- Supervising Controller
- Circuit Breaker
- Publish / Subscribe (of course)
- Dependency Injection, especially constructor injection.
- Unit of Work
- Active Record
Maybe I’ll write some stuff about those another time. For now, I have a presentation to give…
*I’m going to have to do some work on observer. My argument that you can ignore it and skip straight to publish/subscribe was fine as long as the Rx framework didn’t exist.
NOTE: This article gets updated in line with the blog.