Not Against Descriptive Variable Names

I don’t believe we are in any disagreement. I am just using an exaggurated title to clearly highlight my point. It is to provoke some reflection upon how you actually think about naming variables.

It is not merely a question of making them longer, makes them more understandable. Consider something like π, would a long descriptive name really make people grasp what concept we are talking about more easily? Likewise i, j, k as mentioned in whitepaper you linked have very clear meaning to people when used in loops.

Good naming is about a combination of finding good descriptions, utilizing context and relying on well established conventions. My advice on choosing variable names actually has a lot in common with my advice on how to design icons for a user interface.

The equivalent of long descriptive variable names in the icon world are elaborate and detailed icons. A sort of icon giving a little story to explain what it is for. It might make it possible to tease out the meaning of the icon without ever clicking it. However in general designing icons this way is a terrible idea. One of the key points I am trying to drive home about icon design is the utilization of context. When you see a row of these icons, it tell you more than one of them alone:

Image for post
Image for post

Seeing them together gives more information to each of the icons and aid your understanding. Just like when you see tripplets of i, j, k or x, y, z gives more context to understand the indivdual letters.

It is when you cannot utilize context, that more unique icons or longer descritive variable names become more important. However creating a context is somehting you can often do. By naming a series of variables occuring together in a predictable pattern, you create your own little eco-system of variable names.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store