Thoughts on

A blog of various opinions and ideas on development

Demos subscribe via Podcast

Naming: Casing Conventions

Things to consider

Alignment between the casing conventions in the module

My rule of thumb is: Align you casing with the rest of the named variables/functions in the module.

Let’s say you have some module that is processing user input. Your module will receive possibly anything and it’s should be attempting to get a date.

function getUserinputAsDate (userinputString) { /**/ }

See: Naming: Naming Conventions for info about why userinput needs to come first. Now suppose

Ok this is a bit of a contrived example, but I do frequently come across functions that have this setup. The consistent casing on all the variables starting with userinput makes it

Compound and Prefixed words should be considered one word (strong probability)

In the case of ConfigFilename: I think the chances of me wanting to have a script iterate over a list of words blindly splitting on capital letters, or any of the below casing conventions I am going to be annoyed if I see words like Pre & Processor or File & Name.

Mixing casing conventions could have value.

I once told a co-worker this to much of their scorn, but look how well BEM took off. It will always be a hack though. Generally I find if I want to mix casing conventions, it’s because I am fitting multiple types or sources of data into just one field. Here is an example.

Let’s say I am writing a blog post on github, and it requires me to prefix the blog post markdown filename with the date I am writing the blog post. So YYYY-MM-DD. Most developers might do YYYY-MM-DD-my-first-blog-post. Wouldn’t it be better if I used YYYY-MM-DD_my-first-blog-post or YYYY-MM-DD--my-first-blog-post. I like the underscore best because if I ever need to regex the date from the title, I am ready to go. With the double dash, I am sure I could make it work, but with a single dash, I am going to have to have regex available because I need the pattern matching to drop or get the date. But a simple find and replace utility isn’t going to cut it since that can distinguish between the dashes in the date, name, or between the date and name.

Like I said, this will always be a hack, but that’s better than no solution.


It seems to me, the question is if you ever want to mechanically separate the words, then you might need to consider your casing conventions. Let’s also remember the source of casing conventions, a hack to improve the readability of code with limited systems.


Is your system case insensitive?
Quick Examples
tags: Programing - CodingStyle - NamingConventions - ItDepends