Naming Things Made Easy

Posted on July 24, 2020 by Riccardo

We were in the office doing meaningful work. Still people couldn't help but move closer to check what the heck was going on. Some were attracted by what we had drawn on the whiteboard. Others approached us because our discussion had gotten too strange to be ignored:

Let's say the the order is pink but yellow happened, would it become brown or green?

It took Mateusz and me hours to collect all those colors, connect them with arrows and draw everything on the board. We were facing a complex problem. Thus, we reached for unconventional tools to make sense out of it.

Naming Things is Hard

No doubt about it. The problem is, in some situations, it is also unproductive and dangerous.

Giving anything a title is best done at last. It's only when the exploration is done, dust settled down and the result is stable that things can be summarized to a sentence. In other words, naming belongs to the editing phase not the writing one.

Never intermix writing and editing. Writing is a diverging activity. It needs space to expand. Editing is a converging activity. It requires compression. They are opposites, therefore, unless the goal is to achieve a mediocre result, be wise and keep them apart.

Write drunk, edit sober

–Peter De Vries

Code is the result of an exploration: the most promising solution of the ones considered. Breaking the flow to think about a name while generating options is not productive. It doesn't matter if a variable is named isFulfilled or yellow in this phase. Really. It doesn't. So let's just throw a color in there. Or the name of your favourite character in Star Trek. Or anything that does not require a disruptive mental effort.

Naming early is dangerous too. Words carry a mental baggage with them. For example, the word "classroom" seems harmless at first. But wait, in my head I see a physical space, several people sitting in front of small desks, a teacher standing on the opposite side and a ton of other details. I can also smell the chalk. Now I feel it on my fingers. Wow. And I thought I was just naming a variable for an online course platform.

It is incredibly powerful to use the proper word in the right spot. It can be catastrophic otherwise. Choosing the wrong name contaminates our thinking. That is a good way to impair our problem solving skills as highlighted in Starting from the Problem not the Solution and Why Good Solutions Block Better Ones.

I have a secret. The code I write sucks until I edit it. I name things with colors. Sometimes it's even a single character. When I feel lazy I call a class Klass and I likely have twenty-three commits named "wip". I would get lost myself if I had to go back to the code a few days later. But I won't need to because I trust my editing self will do the right thing down the line.

Back to the Office

I wish I had a picture of me, Mateusz and the whiteboard to share here. But it's more than enough to have such a great story in my heart. I like to think that, given our shared passion for whisky, we kinda sticked to the "write drunk, edit sober" plan. And it worked wonders. Thanks Mat!

PinkLetter

It's one of the selected few I follow every week – Mateusz

Tired of RELEARNING webdev stuff?

  • A 100+ page book with the best links I curated over the years
  • An email once a week full of timeless software wisdom
  • Your recommended weekly dose of pink
  • Try before you buy? Check the archives.