Programming on the Toilet

It’s 5PM. I’ve been working on the same code for hours, grinding out an implementation one line at a time. It’s been a torturous process. Some days, code just naturally flows from my brain to my fingertips. This is not one of those days.

I’ve been tasked with adding new functionality to a class. “Easy”, I thought. “I wrote this class, so it shouldn’t be hard to figure out how to extend it.” So, after a delicious lunch, I sat down and started coding.

Things started out all right – I had a vague idea of how the new functionality would fit in the class. However, the deeper I got into my implementation, the more I realized my vague idea wasn’t good enough. Functions needed access to data that wasn’t available to them. I was creating edge cases left and right, making the class much more fragile and bug-prone. On top of that, unit tests were constantly failing when I ran my new code.

I fell deeper and deeper into the rabbit hole over the next few hours, until I could barely recognize the code I had written. I was constantly looking at the diff between my local code and the original to figure out what I had changed. I no longer had a mental model of how the code worked, or how I wanted it to work. Things soon degraded into a battle between me and my computer. “Just compile, damn you, compile!”

So here we are at 5PM – one hour before I go home for the day. I’ve all but given up on finishing the feature today. “There’s no way,” I think. “It would take me an hour just to untangle this mess of code.”

I stand up from my desk in defeat, my head hanging low, and make my way towards the bathroom. I sit down on the toilet, take a deep breath – and that’s when I obtain enlightenment!

The Throne of Inspiration

ToiletSuddenly, I see everything clearly. Code is racing through my mind. I can see the class, all of its functionality and its use cases. I can see exactly where to add new code for the feature. I can see it all!

I finish my business (wash hands before returning to work!) and rush back to my desk to start banging out code. My fingers can’t type fast enough to keep up with the code that’s rushing out of my brain. The keyboard starts losing structural integrity as my fingers hammer it with the force of a thousand suns. The computer and I are no longer enemies – we are the closest of allies, working together with a common goal.

Thirty minutes later, the code successfully compiles. All of the unit tests pass. I run down the list of requirements for the new feature, and each one works as expected. “I’ve done the impossible, I finished it!”

As I come down from my coding high, I reach a single, infallible realization: The most efficient programming I’ve done has not been in front of a keyboard, but on a toilet.

Step Back (From Your Code)

Now, I’m not saying that toilets have magic code-architecting properties (although I do think they’re a great invention). However, I am saying that all but the most trivial coding tasks will be 10x easier if you step away from your computer and think things through at a high level. Whether it’s going to the bathroom, taking a walk to the park, or just sitting in your office kitchen, getting away from your screen will clear your head and allow you to see the forest for the trees.

Many programmers are hesitant to step away from their desks. They consider time spent away from an IDE to be wasted, or worry that they’ll be looked down upon. “Why isn’t he at his desk coding!? Time for that demotion,” their managers will say.

I would argue that this logic is completely backwards and counterproductive. Programmers are not paid to sit at a desk, or to stare at a screen, or even to write code. These are all just steps on the way to a programmer’s real goal: to create functionality for the end-user. If you’re able to create that functionality more quickly and efficiently by stepping away from your desk, then that’s what you should be doing.

In conclusion: don’t forget to use the bathroom while coding.

112 thoughts on “Programming on the Toilet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s