This is one of the points Zachary Tellman makes in his book Elements of Clojure. In this article I elaborate on this idea and give an example of how I applied it in practise.

Many sources discuss how to choose a new name. Tellman made me think of when not to choose a new name.

Names are very useful. They provide a summary of a complex idea, or they serve as a guide to start understanding a complex idea. I would like to elaborate on this further in a future article.

The downside of names is that they introduce something new to be understood and remembered. On top of that, there are only so many names and even fewer good ones. Introducing names with zeal and alacrity will lead to clashes and confusion.

In this article I only discuss non-naming for small compound data. However, Tellman mentions a few more situations where it can be applied. I think most valuable to you, dear reader, is the general notion that perhaps you don’t always need a new name. With this awareness you will discover situations where you find this notion applicable.

Small compound data

Let’s say we have pairs of tutors and students. You could introduce a new name for such a pairing, e.g. a tutelage. Tellman suggests in his book to instead just call it tutor+student. The latter name makes it immadelately clear what it is, because it is just that: a pair of a tutor and a student. A good name, without introducing a new name.

If your language doesn’t allow + in a name, think of something else such as tutor_and_student. Although admittedly a large part of why tutor+student is acceptable is because it’s still short; the more characters you need, the sooner you might find it unacceptable.

I once worked in the codebase for a server with the concept of a context. A context is a compound of an alias, a urn and a param. However, in that same codebase there were four(!) different notions of context. Context is so nice and generic term that it’s an easy name to fall back to.

I got rid of that one particular notion of context by changing the name to alias+uri+param. My colleagues thought that part of the code had become much clearer, thanks in part to the necessity of understanding and remembering what a context is in that particular context (ha).

Let’s look at an alternative. I could have thought of a new name. Maybe elaborated more on what sort of context this is. An enricher-context, perhaps? But is that name really better than alias+uri+param? For typing and reading it’s about as much effort, but the + style name does a better job of being self-explanatory.

Admittedly in verbal communication it was a bit awkward to say ‘alias uri param’.

My take is that naming small compound data in this + way works up to about 2.5 elements that are compounded. By that I mean that it works for sure with two elements but is questionable for three. Four is definitely too many and sadly requires a new name.

Another example

In this advent of code puzzle you are tasked to walk on a grid by following a sequence of instructions: rotate clockwise 90 degrees, rotate counter-clockwise 90 degrees, or take n steps.

When you take steps, your new location will depend on your old location and which way you face (your orientation). In my implementation I make use of location-orientation pairs. I could introduce a new name for such a pair. A placement, perhaps?

No need to ponder on a good name: just call it location+orientation.

Clojure specific

So what about not a single compound, but a collection of compounds? How to name, let’s say, a big list of tutor-student pairs? Tellman suggests tutor+students, admitting there is ambiguity whether what is meant is (tutor+student)s or tutor+(students). If the ambiguity is not cleared by context, he writes, then do introduce new names such as tutelage and tutelages.

To my surprise I discovered this only upon rereading the chapter for this article. It turns out I had misread the first time. I’m glad I made that mistake because it lead me to use a different naming convention, one which I prefer.

What I originally thought to have read was that Tellman suggests to name the collection of pairs tutor+student. This puzzled me: then what to name a single pair in this collection?

It turns out that because the language I use (Clojure) has destructuring, I can do this:

(let [[tutor student] (first tutor+student)])

I don’t have a single word that names the single pair, but the pair is described by [tutor student]. This has its own pros and cons, but overall I like it.

Personally I use this + naming convention and destructuring quite often, for example in the code for a previous article.