Naming things and Cunningham’s Law

Naming things is hard. 

Naming things is very hard. 

And, in software, we often want to name things when we know least about them. We create a variable that we plan to use later. What should it be called? How should it be used? We only have a vague plan at this point. And plans, of course, can change. 

In my mob, we sometimes struggled to name things. And we would then fall into long discussions about what to call a variable. This often felt like bike-shedding, but we wanted a good name, so we carried on talking. 

Then one day, we came up with a new plan. If we couldn’t name something within ten seconds, the person at the keyboard would just hit the keys at random and produce a gibberish name. 

We would then use this unpronounceable name in the code, and move on. 

And, as we moved on, we would have to talk about the unpronounceable thing. So we call it by what is was doing, by how we were using it. And, often, the name would then become apparent. 

By not naming things in our code, by using a deliberately wrong name, we are posting the wrong answer to ourselves. This then invites us, forces us, to correct the name once we understand how we are using it. 

We found this to be far more useful than using a sort-of-correct name. You can leave a sort-of-correct name in. It’s almost right. You can leave it, forget about it and move on. And the next person to read the code will struggle because the names aren’t right. But you can’t leave a name like ghhjygddtv in your code. You have to fix it

Cunningham's Law states "the best way to get the right answer on the internet is not to ask a question; it's to post the wrong answer."

We place ourselves in a temporary position of tension. We know the name is wrong, we don’t know what the right name is, so we proceed with a shallow dive into chaos until we understand enough to resolve the tension and finally give a proper name. 

Comments

  1. Thank you for this inspiring write-up.

    I usually fell into one of two traps: arguing for too long on finding a proper name or sticking to one that feels not right.

    Starting off with gibberish seems to be a great strategy to try out.

    ReplyDelete

Post a Comment

Popular posts from this blog

We always start from where we are

Mobodoro

Gilded Rose Katas