Good Names
Published: 2021-04-17 11:42:05

---
title: Good Names
published: true
date: 2021-03-23 10:44:00 UTC
tags: 
canonical_url: https://kevincox.ca/2021/03/23/good-names/
---

<main><p>Naming is one of the <a href="https://www.karlton.org/2017/12/naming-things-hard/">two hard problems in computer science</a>. Unfortunately I have not managed to solve it but over the years I have come up with some rules to judge how good a name is. In order of importance:</p>

<ol>
  <li>
<strong>Be unique</strong>: If you have a unique name you can look up more information, this makes that the name itself less important as it is supported by documentation.</li>
  <li>
<strong>Don’t be misleading</strong>: Misleading names cause confusion until the reader looks up more information (if they bother to seek documentation at all).</li>
  <li>
<strong>Be Leading</strong>: A great name will give you some hints about what it does so that you have some context before looking it up.</li>
</ol>

<h2 id="explanation"><a href="https://kevincox.ca/2021/03/23/good-names/#explanation">Explanation</a></h2>

<h3 id="uniqueness"><a href="https://kevincox.ca/2021/03/23/good-names/#uniqueness">Uniqueness</a></h3>

<p>By the first rule a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a> is a great name. In fact I have seen a lot of names worse than a UUID over the years. UUIDs even do quite well at rule 2! (The only minor concern is that humans won’t read carefully so two UUIDs with a couple of similar characters at the beginning or end may mislead.) Of course UUIDs are hard for humans to work with and don’t achieve rule 3 at all.</p>

<p>Note that universal uniqueness isn’t required for a name to score highly in this category. A name that is unique in its field is usually sufficient. For example DNS may conflict between the protocol used to look up domains and “Do Not Schedule” events on calendars but this is rarely an issue in practice.</p>

<p>A bad example of uniqueness was a product I worked on called APP. It was a poorly thought out acronym and it was really confusing when our customers were trying to build their app on APP.</p>

<h3 id="dont-be-misleading"><a href="https://kevincox.ca/2021/03/23/good-names/#dont-be-misleading">Don’t Be Misleading</a></h3>

<p>Misleading is problematic for the obvious reason that some people will read the name and assume they know roughly what it is talking about. For example don’t name a dynamic interpreted language JavaScript or name a function that empties a container <code>empty()</code>. This rule can be difficult as projects, functions and everything else changes over time.</p>

<h3 id="be-leading"><a href="https://kevincox.ca/2021/03/23/good-names/#be-leading">Be Leading</a></h3>

<p>It may seem odd that choosing a helpful name is last on the list but this is due to a few important factors:</p>

<ol>
  <li>Compressing a meaningful amount of information into a name is incredibly difficult.</li>
  <li>Since everything changes over time it is even less likely that a name that is helpful when a project is started will still be useful when a project reaches 1.0, let alone a decade or two later.</li>
</ol>

<h2 id="note-on-name-lifetimes"><a href="https://kevincox.ca/2021/03/23/good-names/#note-on-name-lifetimes">Note on Name Lifetimes</a></h2>

<p>The order of the rules is most important for rules that may be used for long periods of time, such as project or company names. Often times this isn’t the case and rule 3 becomes nearly as important as rule 1, for example function names generally have a small scope and are usually able to be deprecated or changed if the name is no longer accurate. But if it is possible to identify a key feature of a project that is unlikely to change—such as Postgre<strong>SQL</strong> or Yugabyte<strong>DB</strong>—it is usuallly a good choice to do so.</p>