Why I hate all articles about design patterns

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

Sometimes play is a lie

Imagine two children, both nine years old, decide to play tea. They rummage around in the closets of their respective parents. They dress up as they’ve seen their parents dress up. The one goes over to the other’s house.

“Mr. Worthington, it is so nice to see you,” says the girl who is acting as host. “Would you like some tea?”

“Why, yes, Mrs. Kentworth, I would be delighted to have some tea.”

The host brings an empty cup of tea to the guest, and the guest pretends to sip at it.

“Why, Mrs. Kentworth, this is such delicious tea!” says the little boy.

“I am so glad you enjoyed it!” says the other little girl.

They talk about their imaginary house and imaginary kitchen.

They are imitating the manners of their parents. This is how children learn. And when children are so young, there is no harm in it. Rather, it is cute and somewhat comical.

For better and for worse, people continue to play when they grow up. This is fine so long as the play is labeled as play. Joyful play is the starting point of creativity. But play becomes dangerous when the people who are playing convince themselves that they are doing real work. If the play is driven by a desire to avoid a difficult topic, then whatever game the adults are engaged in is likely to be destructive to their long-term interests. And such play can be insidiously difficult to spot if the people in question are hyper-intelligent and able to come up with seemingly reasonable justifications for what they are doing.

Imagine two programmers who spend all day discussing Design Patterns. Their conversation sounds like this:

“Why, Mister Yi! How shall we normalize our data? Is Fifth Form enough, or do we need Sixth Form?” said one.

“Why, Mister Kerr! What a delightful question! I suggest the Strategy Pattern. Let’s make normalization levels a configurable, pluggable behavior!”

They are playing.

I once worked at a small startup where the CTO and his buddies were working on a website that gave nurses a way to track patients medical information. When I first spoke with them, I was dazzled by their intellect. I recall our first conversation lasted 4 hours, during which we covered dozens of important topics: how many unit tests are enough, the trade-offs to be made when invalidating a cache, optimizations of TCP, the right length for Git commit messages, when to rebase, the advantages and disadvantages of polyglot programming, how to resolve inconsistency in a distributed database after a network partition, and so on.

Once I started to work with them, my impression of them changed. We had fantastic conversations but we were getting very little work done. Also, they were doing some unusual things, such as storing JSON strings in a text field in a PostGres database. They had done this before PostGres supported JSON. They had begun work in 2011, but they rejected all of the existing document databases (such as MongoDB or Riak). In 2013 they decided to work on version 2.0 of their software, which would be a complete re-write, but they decided to continue to keep JSON strings in PostGres. They liked some of the Python libraries that they had been working on, and they wanted to continue working on them. They were not even adapting to the fact that PostGres had begun to support JSON natively!

Was the work justified, or were they simply engaged in a hyper-intelligent kind of goofing off? This was for a website that was a fairly straightforward CRUD app. They could have used an existing framework (Django, Rails, Symfony, etc), which would have allowed them to develop much faster, and which already had many of the tools they were building. They had spent years doing work which should have only taken a few weeks. But using other people’s code to build a CRUD app is not fun.

Fun is important, because we should all have some fun at work, but at the same time, they were just sort of goofing off, adding in a thousand tasks which they felt were fun, and which let them avoid doing the work which the business actually needed.

Play at work falls into two types:

1.) Learning

2.) Avoidance

The first good, the second is bad. The kind of play that helps foster a deeper understanding of the craft of software is a good thing. But if a team is playing just because they are avoiding some difficult issue about their business model, or they want to avoid talking about their own perfectionism, then that is a real problem.

At the startup, where I worked in 2014, the team was consumed with its own perfectionism. In a sense, they were undone by their own competitive pressures. They admired each other, and they each wanted to win even more admiration from each other, so they were constantly doing complex things that earned real respect from any software engineer who heard about their exploits. But none of it had anything to do with the needs of the business.

I’ve worked for more than one client like this. I sometimes feel some frustration at what seems like too much emphasis on theoretical concerns. In urgent situations, I often suggest we cut a few corners so as to get some important work done. So, I sometimes say that I hate all articles about theoretical subjects such as Design Patterns. Too much theory!

But obviously that isn’t entirely true. My best known essay is “Object Oriented Programming Is An Expensive Disaster Which Must End“. Having invested thousands of hours into studying these topics, we all feel there must be some importance to them.

What is the real point of discussing theoretical issues? I write these essays because I want to write software in the most simple and direct way that I can, while still achieving the safety and reliability that the software needs. That is, I want to be more productive. I feel that discussing theoretical issues can be justified, especially if the articles give advice that really help developers get work done.

Get work done. In this I feel most articles about Design Patterns fail.

Perhaps I’m being unfair to Design Patterns, but those articles seem like the worst kind of tech writing, the most likely to inspire useless discussion that doesn’t help move a team forward. Catering to software developers perfectionism tends to be bad for business. And this particular type of article seems to be the most extreme in that regard.

We should all be on guard against the kinds of discussion that waste time without actually helping us advance the craft of software.

Source