Pattern Abuse

Tony Darugar hates patterns:

I’ve seen more horrendous programming sins committed in the name of patterns than almost any other possible justification.

I’m not sure if it’s really worse than other justifications. “XP” and “agile”, for example, are now being used to justify any (lack of) process not involving upfront design and documentation. That aside, pattern abuse is certainly a real phenomenon.

Patterns are just a form of expression. So saying “It’s a good design because it uses Prototype” is like saying “It’s a good article because it uses sarcasm”.

Tony asks if it’s the “patterns” themselves that are at fault, or the developer:

Is this really a damnation of patterns or the case of a bad developer? My point is, this guy was not born a bad developer. He was quite smart, and could’ve been useful. There are many of this guy running around. I’ve seen them.

I don’t know the guy in Tony’s story, but I’d seriously question how good a developer he is, based on this story. Anyone who thinks using a pattern is sufficient design rationale doesn’t understand patterns or design or both. Any design problem has infinite solutions and there are enough patterns in existence (even counting only the good ones) to justify many of those. So you’ll need something more than “Hey everybody, I used a pattern!” to justify you’ve done a good job.

Patterns are great, but you don’t “design by pattern”. You learn patterns and you code with your own ability and you iterate between the two.

To that end, I found test-driven design amazing when I first applied it, because the rapid code improvement loop meant patterns were just popping out. Only later did I realise how many patterns had just morphed their way into the code. The classes weren’t called “Abstract Factory” and “Business Delegate”. They just were. And, in many cases, I ended up with a far better understanding than I’d gained from just reading about them.

Alistair Cockburn’s Shu-Ha-Ri analogy analogy, taken from Aikido, is worth considering:

What is expertise?  (the Shu-Ha-Ri progression)

  Level 1
  Learning “a technique that works”
  Success is following the technique (and getting a success) 

  Level 2
  Learning limits of the technique
  Success is shifting from one technique to another 

  Level 3
  Fluid mastery - shifting techniques by moment
  Unable to describe the techniques involved

No-one can get to Level 3 expertise on all the patterns and collections out there, but whatever level we’re at, we can acknowledge that the mere application of a technique alone is not enough. Fortunately for martial arts students, they get to learn that lesson pretty quick.

Leave a Reply