There are quite a few casing systems out there. Camel case, snake case pascal case, kebab case and etc. Let’s explore their use case scenarios!
Developers love to use conventions! They help us to organise our code and improve maintainability.
When it comes to naming variables and data structure in our code we use casing conventions to differentiate variable types and symbols.
The followings are the common usage for each casing convention.
Camel Case 🐫
camelCase is for variables, function names, arguments and other generic uses.
Snake Case 🐍
snake_case is similar to
camelCase but we usually choose either one and stick to it for the whole project.
PascalCase — Classes, Struct and other data structure definition
Kebab Case 🍖
kebab-case — HTML classes, HTML tags
UPPER_SNAKE — Constants, environmental variables, configuration variables that will never change throughout the app.
Camel Case vs Snake Case
snake_case is one of the worst things that could happen to your code 😰 .
- It is ugly.
- The way we write our variable names has special meaning behind it.
For example, if we are working on a financial app, we could have 2 variables called
If we name them as
paymentGateway , a fellow developer may think that both variables have different structural types or one of them could be a special variable.