Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between StudlyCaps and CamelCase?

Tags:

psr-2

psr-1

PSR suggests, method names MUST be declared in camelCase and class names MUST be declared in StudlyCaps.

like image 746
kta Avatar asked Sep 23 '15 05:09

kta


People also ask

What is Title case vs Camel case?

Camel case is distinct from title case, which capitalises all words but retains the spaces between them, and from Tall Man lettering, which uses capitals to emphasize the differences between similar-looking product names such as "predniSONE" and "predniSOLONE".

What is CamelCase example?

Meaning of camel case in English. the use of a capital letter to begin the second word in a compound name or phrase, when it is not separated from the first word by a space: Examples of camel case include "iPod" and "GaGa".

What is a sTuDlY cased name?

Alternating caps, also known as studly caps or sticky caps (where "caps" is short for capital letters), is a form of text notation in which the capitalization of letters varies by some pattern, or arbitrarily (often also omitting spaces between words and occasionally some letters), such as "aLtErNaTiNg cApS", "sTuDlY ...


2 Answers

StudlyCaps, also known as PascalCase, implies that the first capital of each subword is capitalized. camelCase implies, like a camel, that the humps are in the middle, therefore the first letter is not capitalized.

Compare Microsoft's standards for .NET.

Other well known capitalization styles are snake_case, where all words are concatenated in lowercase with underscores, and kebab-case, which is identical but uses a hyphen.

like image 71
Niels Keurentjes Avatar answered Sep 21 '22 22:09

Niels Keurentjes


CamelCase is where the first letter of each sub-word in a name is capitalised. The first letter of the whole name can be upper or lower case, and is generally (always?) lower case in programming.

StudlyCaps is a little weird. There are capital letters, but they can be at any letter according to some rule, not just the beginning of a sub-word. The classic example is (was) HoTMaiL.

My understanding of the PSRs is that their intention is that each sub-word should be capitalised in both instances, with classes having an initial upper-case letter and methods an initial lower-case letter.

like image 22
dave Avatar answered Sep 22 '22 22:09

dave