Hey developers !
Today, I will explain what the different most common case styles in programming are.
As you probably already know, you can’t use spaces to name variables, functions, or even instances because, in programming, spaces are reserved characters, which means each word is interpreted as a completely separate thing.
This can sometimes make naming things annoying, especially when the name is long. That’s why there are different case styles, which are specifically used depending on the programming language you’re using, the type of things you’re naming, or your personal preference.
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 styles, 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
On Roblox, the lowercase version can be used for folder names to keep them readable.
As for the capitalized version, it is used for declaring constants or dynamic variables, which are specific values or data items that do not or actively change throughout the program, and are necessary for its execution.
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
This is probably the most commonly used case style on Roblox at this time. It is typically used for most variable 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. It is mostly used for functions name and can also be used for most variables instead of Camel Case.