Blogpost

Why naming things in development is so important (and difficult)

Development

Maybe it's slightly exaggerated, but naming things is really hard! How best to solve that problem and how to find a suitable name? That's what I like to tell you in this blogpost! 👇

Philippe
3 min. reading time
Why naming things in development is so important (and difficult)

During the years I've been a developer there were multiple times where I got stuck on naming a class or function. In some of my side projects even to the point where I lost interest in the whole project because I couldn't figure out what the project should be called. Even though I had a very clear idea what I wanted it to do. 

For instance I once wanted a tool where I could choose multiple out of all the Github repositories I have access too and aggregate those into one feed with all the commits, PR's, issues, etc. But I couldn't figure out what to name the tool. And it never got built.

I could very easily give the piece of code in question a temporary name but let's be honest. There is no such thing as using a temporary name. Because a temporary name will likely be the one that sticks.

Why do I care so much about naming something?

The primary goal of your code is to reduce complexity. Choosing clear names can very much help in this. Naming anything, a function, class or even a variable clearly can make it so much easier to understand your code, and therefore increases its maintainability. Especially if you're not the only developer working on that piece of software. 

I think most developers can agree that the variable "$a" says nothing about what kind of data that variable holds, while "$validLoggedinUser" says quite clearly what you can expect to find in that variable.

How do I name something.

There are a few things that I have started doing to avoid getting stuck on this.

Use a thesaurus
The thing I try first is a thesaurus. It basically gives you alternatives for the word you enter. A thesaurus helps you by giving you a list of ideas that loosely relate to the word you are looking for, which can often spark an idea for a name. I usually use Powerthesaurus

Ask for a second opinion
After I try a thesaurus, I ask developer friends or colleagues what they would call what I'm working on or if a name I had thought up was descriptive enough. A second perspective is always very valuable. That name you thought exactly described what you meant might not be as clear as you thought it was.

Leave it 
Lastly, if time permits it, I leave it for a day or two. This lets me revisit the code with a fresh perspective and maybe that shows me the name isn't descriptive at all, or it tells me I was right on the mark.

Keep it simple

The last advise I can give, is that since our first thought should be about reducing complexity, your chosen name should do that too. Should the name be shorter or longer? In my opinion that doesn't matter as long as the name is descriptive and reduces the complexity it can be however long it needs to be.

What are your thoughts on naming? Do you have any 'rules' you always use for naming your classes, variables, etc? Let me know on Twitter @yinxes!

Rushed into remote

Rushed into remote

Tijs 13 min. reading time

Subscribe to our newsletter

We have a monthly newsletter. Want to stay in touch about all developments in TT? Subscribe here to our newsletter!

Together we create digital experiences

Let's get digital!

Let's take off

Think Tomorrow
Lierseweg 81
2200 Herentals

+32 14 84 91 00
info@thinktomorrow.be

Think Tomorrow. Digital Marketing Agency © 2020 Made with ♡ at Herentals.