Camel Case
As you know, camel case is one of the most famous naming convention. For expressing by joining compound words to variable name in programming language, to capitalize first letter of each word without first word.
camel + case | camelCase |
get + raw + keys | getRawKeys |
It is self-evident that first word is recognized easily, and first word does not need to capitalize. However there is other kind of camel case with expressing to capitalize first word. In general, It is given one of various names according to the notations, as follows.
An Initial Letter of First Word | General Name |
---|---|
lower case | camel case |
upper case | studly caps |
Camel case is used in such as Java and C#. There is custom in Java, camel case and studly caps are used to distinguish class name and method name.
method name | camel case |
---|---|
class name | studly caps |
External Links
Underscore Notation
Underscore notation is another method to join compound words as famous as camel case. It is called usually "snake case". In snake case, convert all words to lower case and Concatenate all words with underscore.
snake + case | snake_case |
get + raw + keys | get_raw_keys |
In underscore notation, all words are written in lower case. Another notation that all words are written in upper case is called "screaming snake case". It is used to name constants in many programming languages.
snake + case | SNAKE_CASE |
get + raw + keys | GET_RAW_KEYS |
Underscore notation, which was changing the delimiter to hyphen, is referred to as "chain case". In addition, as "train case" and as "kebab case".
Within this article, it is collectively referred such underscore and hyphen as "delimiter".
The Purpose
The purpose of camel case and underscore notation are summarized as follows.
When the method to get the current time is named by compound words such as "get current time", if to concatenate simply, it will be seen that the readability is very lower.
In camel case or underscore notation, it can recognize easily the words separated.
original words | get + current + time |
---|---|
camel case | getCurrentTime |
underscore notation | get_current_time |
About Notation
In this article, it is referred to each notation as follows.
Notation | Expression | |
---|---|---|
camel case | lower case | camelCase |
upper case | StudlyCaps | |
underscore notation | snake_case | |
hyphen delimiter notation | train-case |