Case Styles: Camel, Snake and Kebab Case Style
A Case Style is special writing method that is used to write compound words and phrases without spaces. There are various common case styles including: Camel Case, Pascal Case, Snake Case and Kebab Case.
In these case styles, by changing the letters case or using symbols such as _ or – between different words that make up the phrase, the readability of the phrase is maintained in the absence of a space character. One of the special applications of these case styles is in programming languages.
Why expressions without spaces?
In today’s digital world, there are various situations where a compound phrase or word needs to be written without spaces. Examples of such situations can be seen not only in professional applications but also in the ordinary usages such as:
- Writing hashtags
- Assigning URLs to Web pages
- Naming variables, constants and functions in computer programming
In the above examples, it is clearly not allowed to insert a space between different parts of the phrase. You might ask yourself: So, why should I use compound phrases in these cases instead of a simple word and get myself into trouble?!
The fact is that in many cases we have to (like writing hashtags) or we prefer (like naming variables) to use compound and multi-word expressions to be meaningful and convey the concept.
The most common case styles for combining words
There are different case styles for writing phrases without spaces and combining words, among which some of them are more popular, including Camel Case (or a special type of it called Pascal Case), Snake Case and Kebab Case.
Usually, one of these writing methods is chosen depending on different applications, conventions and desires. In the following, we will introduce these methods and express the common uses of each of them.
Note that in all examples below, in order to maintain integrity and simplicity, the methods have been applied to the initial expression: “average employee salary“.
Camel Case and Pascal Case
In the Camel Case (or camelCase) method, the initial letters of all words (usually except the first word) are written in uppercase and the rest of the letters are written in lowercase (Lower Camel Case). If the first letter is capitalized, it is called Pascal Case or Upper Camel Case.
Example: averageEmployeeSalary
Conventional applications: Naming variables and functions in computer programming, writing multi-word domain names in advertisements (to make it easier for the audience to read and remember the site address), writing hashtags.
Snake Case
In Snake Case (or snake_case), the words that make up the phrase are separated from each other with the help of an underscore character (_) instead of a space. In this case style, usually all of the letters appear in lowercase.
Example: average_employee_salary
Conventional applications: Naming variables and functions in computer programming, naming constants in some programming languages with capital letters, writing hashtags.
Kebab Case
In the Kebab Case (or kebab-case) method, the words that make up the phrase are separated from each other with the help of a – instead of a space.
Example: average-employee-salary
Conventional applications: Naming variables and functions in computer programming, assigning urls.
Which case style is better?
In fact, there is no standard or convention regarding the superiority of one method over another. In many cases, depending on the intended application (for example, programming language conventions) and the preference of the user or programmer, the desired case style is specified.
However, Camel Case and Snake Case methods are more popular among programmers compared to Kebab Case.
Case styles at a glance
Case style | Application with examples |
---|---|
Camel Case and Pascal Case | Naming variables and functions in computer programming:
Lower Camel Case: firstName, getData() Upper Camel Case (Pascal Case): FirstName, GetData() |
Other applications:
Writing hashtags and domain names, names of companies or products such as: #ValentinesDay and PowerPoint |
|
Snake Case | Naming variables, functions and constants in computer programming:
first_name, get_data() MAX_VALUE |
Other applications:
Writing hashtags such as: #Photography_Competition |
|
Kebab Case | Naming variables and functions in computer programming:
first-name, get-data() |
Other applications:
Web URLs https://techdic.ir/definition/kebab-case/ |
Post image: Technology photo created by pressfoto – www.freepik.com