Compound Naming Conventions in Programming

👇 Get new sketches each week
As Phil Karlton’s famous saying goes: “There are only two hard things in Computer Science: cache invalidation and naming things.”
And because naming things usually involves stringing multiple concepts together using several words, it becomes important to figure out how to do this in such a way that a developer could read it and understand it, as well as the computer (and perhaps help an AI agent, too). Hence the evolution of programming naming conventions, or more specifically, identifier naming conventions.
Each programming language and community tends to have its own conventions for naming things depending on context. For example, a variable or function might use one convention, while a class name might use another. So the naming convention used might tell you not just what the thing is, but also what type of thing you're dealing with.
Identifier Naming Convention Examples
These are a few common conventions:
camelCase: lowerCamelCase and UpperCamelCase
In camel case, words are strung together without spaces or other dividing (or delimiting) characters. Technically, camel case includes both:
- lowerCamelCase — where the first word is without a capital letter, and then each subsequent word is distinguished by a capital
- UpperCamelCase or PascalCase — where all the words start with a capital letter to show where each word begins and ends
Depending on the name, it can look satisfyingly like a camel hump if you have the right names. However, it would be quite the camel with more than two humps.
CamelCase has a long history, but the longevity and popularity of Java and JavaScript certainly did much to make lowerCamelCase ubiquitous.
UpperCamelCase is also known as PascalCase after the Pascal programming language. It’s used a lot in C#, and Python uses it for class names but calls it CapWords.
kebab-case
Kebab case keeps each of the words lowercase but separates each with hyphens. Sometimes it can look pleasingly like a kebab: font-size-large
Though it would benefit from seeing the rest of the stick out the end, imho.
You can’t use kebab-case in some languages because the hyphen is also used as a minus. You may recognise kebab-case from CSS and HTML where it’s common.
snake_case
Snake case avoids all capitals but strings words together with underscores.
I remember an argument that snake_case was preferable to kebab-case because if you double-click in a snake_case identifier, your editor typically selects the whole name including all words. If you do the same with a variable name in kebab-case, you’ll find it only selects the word you clicked on. Bug or feature?
SCREAMING_SNAKE_CASE
Ok, I mostly included this because it has such a great name. And stringing together all your words in full capitals with underscores is bound to make an impression.
SCREAMING_SNAKE_CASE is often used for constants and configuration values, where the capitals help them stand out.
How We Signify Concepts Beyond Programming
It’s not just coding that has to deal with signifying that multiple words together are really just a single thing. I often find myself noticing the ways people connect concepts together.
In text, we Sometimes Use Capitals, or “put things in quotes” (I’m used to using ‘single quotes’ in British English), or use italics as I did above, or connect it with bold. Other times you might use parentheses (left and right brackets)—or separate or surround a concept with em dashes—or use the classic hypertext underline and/or colour to connect multiple words in a link. Using:
- bulleted lists
- or numbered lists…
…also works outside of a novel.
In some places we mix text and computing. It was a minor innovation to start using # to create hashtags that are both easy to read by computers and people alike: #nofilter. Similarly, for the convention of using @ to refer to someone or something with @jonohey. Although, I’m always lost with hashtags and @s as to which naming convention to use: #worldbookday, #WorldBookDay, #world-book-day, @JonoHey, @jonohey. Who knows?
Each of these methods use a text convention to connect concepts together.
In graphic and information design, we face the same challenge but have more tools at our disposal. We signal concepts using colour, font, font size, alignment, layout, background, direction and others. And just as in programming, the treatment you choose can indicate both which words belong together and the kind of thing they are.
It’s interesting to look at, say, an event poster and pick out the ways the designer has signalled different pieces of information using graphical styles.
Did I miss any good ones?
More Two Hard Things
Long ago, Martin Fowler collated some variations of Two Hard Things I enjoyed:
There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
-- Leon Bambrick
There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery
-- Mathias Verraes
There's two hard problems in computer science: we only have one joke and it's not funny.
-- Phillip Scott Bowden
There are so many variations on the “there are only two hard problems in computer programming...” joke that I’m starting to suspect that programming isn’t actually very easy.
-- Nat Pryce

