> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Naming Conventions Matter: Making Wrong Code Look Wrong
- URL: https://nolongerset.com/naming-conventions-matter/
- Published: 2021-10-15T02:56:26.000Z
- Updated: 2026-05-08T13:01:52.000Z
- Description: Joel Spolsky and Antonin Scalia join forces to help illustrate the importance of sensible code naming conventions.
- Author: Mike Wolfe
- Tags: Conventions, Commentary, Humorous, #Import 2026-05-20 02:59

"It is more like judging whether a particular line is longer than a particular rock is heavy."

Justice Antonin Scalia's [famous phrase](https://www.law.cornell.edu/supremecourt/text/486/888) highlights the absurdity of comparing two fundamentally different things. Consider the function below:

```vba
'This function calculates the difference between
'    the length of a line and the weight of a rock
'Returns the value rounded to the nearest tenth of a Scalia
Function ComputeRockLineDelta(LengthInInches As Double, _
                              WeightInPounds As Double) As Double
    ComputeRockLineDelta = Round(LengthInInches - WeightInPounds, 1)
End Function
```

Sample usage:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/10/image-43.png)

A 34.8-inch line is 2.5 Scalias longevier than a 32.3-pound rock. #science

This little *reductio ad absurdum* demonstrates the value of a strong naming convention. By including the units in the variable names–*LengthIn*Inches** and *WeightIn*Pounds–**we provide a glaring visual cue that something is not right. There is no sensical way to compare the length of a line to the weight of a rock.

Although, if such a feat were ever made possible, I propose the unit of measure for the difference be called a Scalia.

## Making Wrong Code Look Wrong

My favorite story illustrating this concept is Joel Spolsky's seminal article, [Making Wrong Code Look Wrong](https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/).

In yesterday's article, *[Beware the BETWEEN](https://nolongerset.com/beware-the-between/)*, I wrote about the dangers of using the BETWEEN clause to filter on date fields that include a time portion. For the field name, I used the wonderfully ambiguous term, *OrderDate*.

A better [date field naming convention](https://nolongerset.com/date-field-naming-convention/) would [make wrong code look wrong](https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/) in my first two examples. Observe.

### Right Code

The "On" suffix signals that we can "get away" with using the BETWEEN statement for our date filter. It's still not ideal. If any values accidentally get added to the table with a time portion then we could be in trouble. In general, though, this code looks correct:

```vba
PreviewReport "OrdersByDate", _
              "OrderedOn BETWEEN #10/1/2021# AND #10/31/2021#"
```

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/10/image-42.png)

### Wrong Code

Hopefully, seeing the "At" suffix on the *OrderedAt* field name will be enough of a reminder that this field contains a time portion. The inclusion of a time portion means the use of the BETWEEN statement will almost certainly return unexpected results:

```vba
PreviewReport "OrdersByDate", _
              "OrderedAt BETWEEN #10/1/2021# AND #10/31/2021#"
```

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/10/image-41.png)

With a strong and consistent naming convention–and enough experience working with it–we can **make it harder for bad code to slip by unnoticed**. For example, queries that use the BETWEEN keyword in combination with a date/time field ending in the *At* suffix should send up red flags.

I mean, that would be, "like judging whether a particular line is longer than a particular rock is heavy."

---

### Referenced articles

[Beware the BETWEENUsing the BETWEEN clause with date-time fields may lead to unexpected results. There’s a safer alternative.![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/10/pumpkin-4597886_1920.jpg)](https://nolongerset.com/beware-the-between/)

[Database Date Field Naming ConventionNaming is hard. When it comes to naming conventions, the key is to keep things simple. Here’s how I like to name the date and time fields in my databases.![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/09/dave-hoefler-Foei3c2jYq4-unsplash.jpg)](https://nolongerset.com/date-field-naming-convention/)

### External references

[BENDIX AUTOLITE CORP. v. MIDWESCO ENTERPRISES, INC., et al.![](https://www.law.cornell.edu/sites/www.law.cornell.edu/files/favicon_0.ico)LII / Legal Information Institute![](https://www.law.cornell.edu/images/liibracketlogo.gif)](https://www.law.cornell.edu/supremecourt/text/486/888)

[Making Wrong Code Look WrongWay back in September 1983, I started my first real job, working at Oranim, a big bread factory in Israel that made something like 100,000 loaves of bread every night in six giant ovens the size of…![](https://i0.wp.com/www.joelonsoftware.com/wp-content/uploads/2016/12/11969842.jpg?fit=192%2C192&ssl=1)Joel on SoftwareJoel Spolsky![](https://i0.wp.com/www.joelonsoftware.com/wp-content/uploads/2016/12/11969842.jpg?fit=400%2C400&ssl=1)](https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/)

*Image by [Magnascan](https://pixabay.com/users/magnascan-653134/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=580333) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=580333)*