Introduction
Hey There !
As you probably already know, you can’t use Spaces
to name Variables
, Functions
or even Objects
because in programming, spaces are reserved characters, which mean each words are interpreted as a completely separate thing.
So it can sometimes be annoying to name things, especially when it is a long name, and that’s why there is differents Case Style, which are specifically used depending of your preference or the programming language you’re using.
Let’s say we have a Variable named like this:
local number of coins = 25
As we can’t use spaces, the variable name have to be changed to this:
local numberofcoins = 25
This would be pretty hard to read the code if all Variables and other things are named like this one…
So it’s time to check out what are the different Case Style, which will help you to make your code better readable overall.
Snake Case
The Snake Case style has each word separated with an underscore character: _
There are 2 type of Snake Case style, having all letter being lowercase or an all-caps version.
local number_of_coins = 25
local NUMBER_OF_COINS = 25
Snake case is mostly used for creating Variables, Methods names and also files names to keep them readable.
You will typically encounter it the most when programming in Python.
The capitalized version is used for declaring constants in most programming languages, which are data items whose value doesn’t change throughout the life of a program.
Camel Case
The Camel Case style start by making the first word lowercase, then capitalize the first letter of each word that follows.
local numberOfCoins = 25
In this variable numberOfCoins
, the first word number
is lowercase, then the first letter of the second word, Of
, is capitalized, as the first letter of the third word, Coins
.
You will encounter Camel Case in Java, JavaScript, and TypeScript for creating Variables, Functions, and Methods names.
Pascal Case
The Pascal Case style is similar to Camel Case, the only difference between the two is that it require the first letter of the first word to also be capitalized.
So, when using Pascal Case, every words start with an uppercase letter.
local NumberOfCoins = 25
This is also my favorite one as it look a way better and proper than other one in my opinion, and it can be used for everything in any programming language.