From time to time, developers will come to my desk seeking advice. There’s a problem they’re trying to solve, they’ve got a couple of possible solutions, but they’re not sure which one to choose.
I start by asking them what the problem is. Next I ask them to explain to me the different solutions they are considering. To be honest, I usually only have a vague understanding of what they’re talking about. However, I nod and make encouraging noises.
When they finish explaining the different solutions to me, I say this:
“What’s the simplest thing that can possibly work?”
They’ll think for a bit. There might be a bit of debate between them. Once again, I won’t really understand what they’re talking about.
Eventually, they’ll reach a consensus and tell me which is the simplest option. Then I’ll say:
“Well, that’s what I think you should do”
They’ll nod vigorously. “You’re right Ben, that is definitely what we should do”, they’ll say. They walk away, pleased to have found a direction forward. I return to my work, still not really having much of a clue as to what they were talking about.
The idea of Doing The Simplest Thing That Can Possibly Work (If You’re Not Sure What To Do Next) is the single-most important engineering guideline I have found in my career.
For brevity in this post, I’m going to simply refer to it as Doing The Simplest Thing That Can Possibly Work. However, it’s important not to entirely forget the second, parenthesised part of the decree. In the case of my developer colleagues, we already knew that they weren’t sure what to do next – that’s why they’d come to seek my advice.
But sometimes people don’t know what they don’t know. So, as well as talking about what it means to do The Simplest Thing That Can Possibly work and why it’s so important, in this post I will talk about why you mightn’t really know what to do next (even if you think you do).
Solving real problems
Doing The Simplest Thing That Can Possibly Work means that you solve the real problem in front of you, not imagined problems. It means that, given the option of choosing to do something now, “just in case”, or deferring that decision, you err towards the latter.
Why do this? Because a codebase represents the culmination of all the decisions that have been made about that project or product so far. The tradeoffs and consequences of each decision compound the complexity of those that have come before. When you make a decision earlier than you need to, you prematurely accelerate the complexity of your system.
The irony is that, because the purpose of our software is to insulate end-users from some inherently complex part of the world, you don’t need to seek-out complexity. It will come and find you eventually anyway. The only question is how weighed down you will be by additional complexity of your own making.
Doing The Simplest Thing That Can Possibly Work means continually picking the line between over-engineering and under-engineering solutions to problems. This is hard, and sometimes involves value judgements. Yet I believe that, after actually delivering software, correctly navigating this course is our most important job as software developers.
Doing The Simplest Thing That Can Possibly Work also means you use the tool that is most appropriate for the job, rather than the tool that happens to be hot right now. It also means you don’t succumb to the streetlight effect of focussing on the problem you know how to solve, rather than problem you need to solve.
Doing The Simplest Thing That Can Possibly Work means you avoid wasting time agonising over unnecessary decisions, which in-turn causes you to neglect other, more mundane-but-important areas of our systems. In other words, it helps avoid systems that are over-engineered in all the wrong places and under-engineered everywhere else.
Doing The Simplest Thing That Can Possibly Work means recognising that, if some code doesn’t seem worth the effort of testing or documentation, it’s probably not worth having that code at all. Nothing seems to focus the mind of a developer (and the volume of code they produce) like the prospect of having to rigorously test and document everything they do.
Writing boring code
If all of this sounds kind of boring, you’re both right and wrong.
Doing The Simplest Thing That Can Possibly Work means that you aspire to write boring code. This is code where people look it and say “Oh yeah, that seems straightforward, I get that”, and move on. You try and contain the areas of unavoidable complexity in small, isolated, well-commented chunks. You adhere to the principle of least astonishment.
And what’s even better than boring code? No code. For many developers, the sweetest feeling of all is deleting code, or managing to avoid having to write it in the first place. The best developers work hard to avoid work.
Don’t get me wrong – you won’t necessarily achieve perfection in one hit. It might take a couple of iterations. This is a perfectly valid approach. I call it the Think a Bit, Code a Bit, Test a Bit strategy. The key part is that, after getting something working, you follow-up and repeat the loop until you have stripped things back to the bare minimum needed. That way, you won’t be condemning future developers to have to pick apart the necessary, inherent complexity in your code from that which is unnecessary.
Doing the Simplest Thing That Can Possibly Work means that you’re not afraid to start small, knowing that a series of seemingly tiny changes can still quickly grow into a (necessarily) complex system. It’s also about having faith that you’ll be able to learn and adapt as your understanding of the problem evolves.
So whilst the end result might be boring, the process can actually be quite challenging. It might not be the challenge you envisaged for yourself when you got into this business, but it’s still a challenge. It’s also a challenge that will lead you to a deeper understanding of the tools that you’re using, and push you to learn better ways of doing things, rather than churning out cookie-cutter code.
This is where we start to question whether, when we say we know what to do next, we really know.
Doing the Simplest Thing That Can Possibly Work comes with the assumption that you don’t know what to do next. This is hard for some people to admit. It is acknowledging the inherent chaos and unpredictability of the world. It is accepting the limitations of our ability to reason about and predict the future.
However, it is also a relinquishment of over-engineering’s illusion of control. Our systems are sufficiently complex that we cannot hold them all in our heads any more. Some people may be able to hold more in their head than others, but everybody has their limit.
Some people hope that, having written the code once, they’ll never have to work with it again. Consequently, they try to get everything right the first time. I gave up on this practice long ago. Very occasionally, I’ll pre-emptively put something in because I know I’ll need it tomorrow, or maybe next week. However, I don’t pretend to have much idea what’s going to happen beyond that.
Doing the Simplest Thing That Can Possibly Work is recognising that today’s greenfield project is tomorrow’s legacy system. It is acknowledging that systems naturally decay, software rots, and entropy increases as we move towards the heat-death of the universe. That might sound grim, but accepting it is actually liberating. The Buddha would have been a good software developer.
In the face of all this uncertainty, Doing The Simplest Thing That Can Possibly Work also means creating an environment that can support the level of change you need. For most non-trivial projects, automated tests give your team the confidence to touch things without fear of breaking them. This in-turn enables a culture of continuous refactoring, which leads to avoiding difficult-to-understand code and saves you from an exponential proliferation of bugs. Finally, for any project bigger than one or two people, a peer-review process gives everybody their best opportunity to have a say regarding whether new code: 1. Works; 2. Makes sense.
Finally, Doing The Simplest Thing That Can Possibly Work is about acknowledging that we are all learning here. In making decisions, we sometimes make mistakes. In making mistakes, we learn. A codebase is a representation of what your team has learnt about your project or product during its lifetime. The learning and the building are tied together.
But sometimes, people over-engineer to avoid the risk of making a mistake. They prefer to put something in now “just in-case”, rather than risk looking bad if they leave it out and it turns out to be necessary later.
This results in a codebase muddied by code whose validity has not been confirmed by real-world experience. It will confuse other developers on your team, both now and in future. Time spent understanding unnecessary code is a waste. It can even confuse future-you. Ever stumbled upon a piece of code you once wrote and wondered: “what was I thinking?” It’s even worse when you finally realise that the code is solving a problem that never actually eventuated.
We are learning more often than we realise, let alone care to admit. But acknowledging that we don’t know something, then Doing The Simplest Thing That Can Possibly Work, is often the best way to move forward, learn and build something.
Let’s Wrap This Up
The principle of Doing The Simplest Thing That Can Possibly Work can be applied by both an architect flying at seventy thousand feet, or a newly-graduated developer deep down in the weeds. Timeframes and abstraction levels can vary, but the principle remains the same.
This principle won’t eliminate all complexity from your life, nor will it eliminate the need to use your noggin. However, it will improve your ability to find the balance between over-engineering and under-engineering a solution to a particular problem.
When I ask developers “What’s the simplest thing that can possibly work?”, I’m asking them to look for this equilibrium point (even if I don’t really understand the discussion that follows). I’m also asking them to be the best developers they can be. Life’s too short for unnecessary complexity, especially if it’s because we can’t admit to ourselves that we don’t know something. The world is already complex enough. Let’s not make it worse.