DEV Community 👩‍💻👨‍💻

Cover image for Four Case Styles you should know!
SYED MAZHAR ALI RAZA
SYED MAZHAR ALI RAZA

Posted on • Updated on

Four Case Styles you should know!

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:

  1. Camel case
  2. Pascal case
  3. Snake case
  4. Kebab case

Camel Casing:

camelCase
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:

PascalCase
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:

kebab-case
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:

snake_case
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 (0)

🌖🌗🌘 Turn on dark mode in Settings