I can’t be the only one who forgets what naming convention I should be using between different languages. Especially as there are variations between each one.

So, just so that I could see how many I could cover, I thought it would be a great idea to make a list here, with a brief description of each type, and any varying names that come with them. Hopefully, writing them down and looking into each one myself would help it stick.

This isn’t a conclusive list. Not yet, at least. I’m not covering every obscure one. For now, it’s just a brief introduction to some of the most widely used naming conventions and some of the ones that I use on a regular basis.

Naming conventions aren’t just used to name variables in programming languages either, they can be used in file names, folders and even company names. Like iPhone and ebay using the first case on the list.

Camel Case

Sometimes called Camel Caps, this is one of the most widely used naming conventions and can be spread across most of the programming languages.

It’s used with the capitalisation of every word except the first letter, so deanPugh, camelCase or thisIsAVariable. Sometimes this can be referred to as the Lower Camel Case.

Other variations of this extend to capitalising the first letter, so DeanPugh or CamelCase for example. This way is called the Upper Camel Case, Captial Camel Case, or more commonly, Pascal Case.

Snake Case

Snake case involves separating the words with an underscore, like dean_pugh or snake_case. Most commonly used with lowercase letters, although I have seen them used with capital letters in things like session variable names.

Kebab Case

Kebab case is very similar to the Snake Case, except that it separates each word with a hyphen. This style is widely used in CSS files as people style their websites. So you would see dean-pugh or kebab-case.

Flat Case

Simply typing out your variables in lowercase is called Flat Case. No requirement for hyphens or underscores, or even separating out each word with a capital.

Using a flat case does make things very difficult to read on occasion. It’s the same reason that there have been some monumental Hast Tag fails because it uses a flat case.

I won’t list too many fails here, because most of them end up a little x-rated. But the hast tag for Powergen Italia looks bad as #powergenitalia.

Upper Case

I’m not totally sure if Upper Case requires you to use underscores between each word. I have seen examples of using underscores and some without. So just Flat Case with the caps lock on.

I have used Upper Case with underscores, which I use for temporary variables within PHP. I’m not sure that’s what anybody else does, but it works for me.

Studly Caps

Studly caps is probably not something you may see in many code bases, but it’s interesting enough to be worth a mention.

It requires more effort to both type and read than the other cases mentioned above. So the reason for using it must allow for something that the others do not.

If you are constrained by white space but want to use or have restrictions on naming, then this can save the day.

Also, Studly allows for hidden words within itself, Hotmail was originally stylised as HoTMaiL with includes HTML as upper-case.

Conclusion

Some of these have a use for different languages or different environments. I currently tend to stick to Snake case for PHP, kebab case for CSS, and Camel Case for anything else. There aren’t many options when it comes to naming conventions, and are often created in languages based on requirements or restrictions.

If you have anything interesting that you think I should add to the list, then let me know in the comments below.