cft

Four Case Styles you should know!

While programming, there are certain naming conventions used for naming variables, functions, classes, etc. This article features the four most popular case styles used for the naming convention in programming.


user

Syed Mazhar Ali Raza

2 years ago | 1 min read

In programming, we are mostly not allowed to use space characters between words because it is interpreted as the end of an 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:

For using the camel case style, the rule is to remove spaces and capitalize each word, except the first one.
Example: 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.
Example: 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.
Example: 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.
Example: 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.

Upvote


user
Created by

Syed Mazhar Ali Raza

I am a 20 year old engineering sophomore pursuing BTech in Electronics and Communications. I am a frontend web developer proficient in HTML, CSS, and JavaScript and have a vision to become a full-stack developer (tech stack: MERN).


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles