The Naming Problem

The Naming Problem

A famous quote by Phil Karlton reads, "There are only two hard things in Computer Science: cache invalidation and naming things."

Leaving aside cache invalidation, which we can return to another time, why should naming things be so hard? Giving names to objects around us seems to be an innately human activity. It is one of the first things babies do when they begin to talk.

Naming things

Considering just computer science, we cannot deny that we developers have difficulty naming our artifacts: whether variables, classes, functions, or whatever, the names we assign are often not the best we can do.

Perhaps we are too focused on quickly finding a solution to the problem we are solving and do not pay attention to a fundamental side effect of our work: communicating with others.

So, by naming a variable x or y, we are not wasting our valuable time thinking about what that variable might communicate to a colleague who is unaware of what is going on in our minds. At most, we can use temp for a temporary variable, or myDate for a variable intended to hold a value of type date.

But even when the effort is considerable, as in the case of a variable called startDate, we very often forget to adapt the initial name to the changing needs of the context. And so it can happen that what was a variable designed to hold the start date of a contract becomes a subscription date, but keeps the same name startDate, creating ambiguities that will sooner or later lead to bugs.

Names and ambiguity

Ambiguity: this is a word that computer folks should be very familiar with. One of the requirements for a programming language to work properly is the absence of ambiguity. There can be no constructs that a compiler or interpreter cannot recognize the unique meaning.

Humans are experts at ambiguity. Very often we can solve it, and sometimes we even like to play with it. But not machines. Neither is artificial intelligence, which can do it in very narrow contexts, but I don't think they are yet able to grasp the humor that sometimes lurks in ambiguity.

So-called formal reasoning does not like ambiguity either. The way of thinking of scientific-mathematical disciplines, to which computer science should belong, requires that concepts be well defined and possibly identified by a name. A name that often sums up the concept definition and is therefore literally meaningful. Without bothering Plato, the name must recall the concept definition, so that, for example, a triangle is something that has three angles and cannot have four.

Names and communication

The fact that a name should evoke the definition of the object or concept it describes seems obvious. Unfortunately, outside of academic circles, this is not so obvious in computer science.

In my experience, I have encountered several instances of miscommunications caused by ambiguity or ad sensum interpretation of the names of computing objects and concepts.

Have you ever encountered people confusing a blog with a blog post? Or a domain with a URL? I have, very often. But I am not talking about juniors, even seniors with several years of experience behind them.

Even on the meaning of session, you can see countless diatribes: so many confuse the concept of session with its implementation (e.g., based on the use of cookies on the Web) or the persistence of data associated with it (e.g., session storage).

Not to mention one of the most misunderstood technologies: REST. The vast majority of developers do not even know what a state transfer is in this context, which is also a fundamental part of both the acronym and the architectural paradigm.

The Latins used to say nomen omen, meaning that a name carries with it its destiny, its ultimate meaning. But if we cannot interpret a name correctly, how can we understand its meaning?

What is behind a name

Galileo wrote: "Names and attributes must be adapted to the nature of things, and not the nature to the names; for first were the things, and then the names”. Naming is an activity of adapting language to reality. And perhaps therein lies the essence of the complexity of this seemingly simple activity.

I have always been fascinated by the story behind a name: its original meaning, its evolution in both form and meaning. It helps give me the idea that it is not just a label, but something alive.

I understand the effort behind choosing a name: from one for a baby to one for an animal, from one for a company to one for a product. A series of attempts, many of them unsuccessful, with the intention of describing the concept, the project, or the person in the best possible way. Or simply a name that pleases and evokes a certain feeling.

Naming things is not easy, but it is part of human nature. Naming is a bit like giving life, like marking destiny. It should not be done lightly, because the name identifies the object, and the name and the object become one.

This should apply to everything, including variables, because, as Albert Camus wrote, "to name things wrongly is to add to the misfortune of the world”.

But sometimes names tend to take on an existence of their own, disconnected from the real object. And in some cases, the name is the only thing we have left when the real object no longer exists.

Stat rosa pristina nomine, nomina nuda tenemus