Naming Conventions — Camel Case, Pascal Case, Kebab Case, and More
Consolidated list of all naming conventions
As a programmer, we always strive to make our code readable, maintainable, and consistent to ensure that it endures for a longer period.
We can accomplish this by writing clean code, and one of the most crucial and fundamental components of producing a clean code is the naming conventions we employ.
Below is an overview of the naming conventions used in programming languages. Out of them Pascal Case, Camel Case, Snake Case, and Kebab Case are the most popular and widely used across programming languages.
Pascal Case
Also known as Upper Camel Case or Studly Case, this notation is formed with every first letter of a word with a capital letter. In the case of names with multiple words, all words will start with capital letters.
Eg: FirstName, LastName
This naming convention is mostly used to name Classes in the programming languages like C#, JavaScript, Java, and Python.
Camel Case
Also known as Lower Camel Case or Dromedary case, which is formed by every first character starting as a lowercase letter. In the case of names with multiple words, the adjacent name starts with a capital letter.
Eg: firstName, lastName
This naming convention is mostly used to name variables, functions, and methods in programming languages like JavaScript & Java.
Snake Case
The snake case is also known as the pothole case. It is written by separating the word or character by an underscore “_”. Also, all the letters are in lowercase.
Eg: first_name, last_name
Snake case is widely used in naming variables, functions, and methods in the Python programming language.
Kebab Case
Kebab case is also known as Dash Case, Lisp Case, and Spinal Case. It is similar to the snake case but instead of an underscore we use a hyphen over here “-”.
Eg: <navigation-drawer>
We mostly use this naming convention to name our custom HTML elements.
Flat Case
In the flat case, we name the variable by combining all the words and letters without leaving any space in between. All the characters in the flat case are in lowercase.
Eg: firstname, Lastname
This convention is very less often used as it affects readability especially when multiple words are combined.
Upper Flat Case
This notation is formed by combining all the words and letters without any space in between with all the letters in upper case.
Eg: FIRSTNAME, LASTNAME
Similar to the flat case this convention is hardly used as it affects readability when multiple words are involved.
Pascal Snake Case
The Pascal Snake Case is formed by combining the rules of pascal and snake cases. It is formed by capitalizing the first letter of each word and separating these words with the underscore “_”.
Eg: First_Name, Last_Name
This convention is observed in legacy Java packages.
Camel Snake Case
Similar to Pascal Snake Case, this convention is formed by combining the Camel and Snake Case rules. Over here, the variable name starts in lowercase and is separated by an underscore “_”.
Eg: is_Valid_Customer
Screaming Snake Case
The screaming snake case variable is created by using all capital letters of the words separated by an underscore. It is also known as a Macro or Constant Case.
Eg: MAX_AGE, MIN_AGE
Most programming languages use this format to declare constant variables.
Train Case
The train case is also known as the HTTP header case. It is formed by capitalizing the words’ first letter and separating them with a hyphen.
Eg: Content-Type, Content-Length
You will mostly see this convention is used in HTTP header requests and responses.
Cobol Case
The Cobol case is again a combination of upper flat case and kebab case rules. The variable is named by capitalizing all the words separated by a hyphen.
Eg: END-CALL
As the name implies, this convention is majorly used in the COBOL programming language.
Each programming language comes with its own style guides, and you will find some of them using the above conventions as per their style guide. Hence, it is advised to follow the style guide of the programming language which you are working with. But ultimately the style guides will mostly adhere to the above conventions.
Thanks for reading.