In programming, we are mostly not allowed to use space characters between words because it is interpreted as the end of identifier or beginning of something new.
Instead, we use certain naming conventions in order to use multiple words for naming variables, classes, functions, etc. in the source code.
Following are the most popular case styles used in programming:
- Camel case
- Pascal case
- Snake case
- Kebab case
Camel Casing:
For using the camel case style, the rule is to remove spaces and capitalize each word, except the first one.
Eg: first name
will be written as firstName
in this case style.
Application: The camel case style is used as the naming convention of variables and functions in various programming languages like JavaScript.
Pascal Casing:
For using the pascal case style, the rule is to remove spaces and capitalize each word, including the first one.
Eg: first name
will be written as FirstName
in this case style.
Application: In Java, all classes, interfaces and enums are expected to use Pascal case. C# uses PascalCase for namespaces and even public methods.
Kebab Casing:
The craving makes it difficult to write but by gathering all my self-control, here I go. The rule for kebab casing is to remove spaces and then add a hyphen "-" between each word.
Eg: first name
will be written as first-name
in this case style.
Application: In CSS, property names are written in this style. This style is also often used in URLs.
Snake Casing:
For using the snake case style, the rule is to remove spaces and add an underscore "_" to separate each word.
Eg: first name
will be written as first_name
in this case style.
Application: It is used conventionally in declaring database field names. Python uses the style for variable names, function names, method names, and module or package (i.e. file) names. PHP uses SCREAMING_SNAKE_CASE for class constants.
Top comments (1)
A great breakdown of the four main case styles in programming: camel case, pascal case, snake case, and kebab case. Each style has its own set of rules and applications in different programming languages. Camel case is used for variables and functions in languages like JavaScript, Pascal case is for class names in languages like Java and C#, snake case is commonly used in Python and for database field names, kebab case is seen in CSS and URLs, and SCREAMING_SNAKE_CASE is used for constants in languages like Python and PHP. It's important to follow the right conventions for readability and consistency in your codebase.
For switching between these case styles quickly, check out our converters: camel case converter, pascal case converter, snake case converter, kebab case converter, screaming snake case converter.