Snake, Camel, Dromedary cases

Miles Murdocca
Thu, 15 Apr 2021 04:35:56 +0000
How-Tos

When it comes to naming in computer programming, we have our go-to’s “foo” and “baz” for quick name choices, for files or variables or functions. But it is considered best practice to use more meaningful names like “TaxTips.txt” or “Vacation_Photos_2021”.

We have case types too. In the olden days, metal type is stored in wooden cases in pullout drawers, one drawer per font and size. A composer removes a case and places it on an easel, and uses a composing stick to arrange the type pieces into a phrase that is then placed into a chase for printing. The capital letters ‘A’, ‘B’, ‘C’ appear above the small letters ‘a’, ‘b’, ‘c’. Thus “upper case” refers to capital letters while “lower case” refers to small letters.

In programming, there are three commonly used combinations for the cases, stylized like this:

snake_case [all words in lower case separated by underscores]

CamelCase [two humps (every word starts with an upper case letter)]

dromedaryCase [one hump (starts with lower case, then each new word starts with upper case)]

Note: dromedaryCase is often referred to as camelCase which confuses with CamelCase.

There are lots more like flatcase, UPPERFLATCASE, dash-case, SCREAMING_SNAKE_CASE, others. I don’t know how snake case got its name. I sometimes mix them up in my code because I start one way but then import code done another way, and it gets confusing as to which are function names versus which are variable names or other entities.

The thing is, it doesn’t matter for functionality, unless the application is purposely sensitive to it like table names in a SQLAlchemy database. It’s just a style convention and not everyone adopts the same style for the things that they name.

I like desert animal names. Can you think of another that maps to a naming style?