问题
I constantly forget which is Camel case and which is Pascal case. So I thought that maybe a little history will help. Where do the names of these conventions come from? Is there some history behind their names?
回答1:
To remember camel case you have to think about the shape of the capital letters. They are like the humps of a camel as you can see in this image.
Pascal Casing - capitalizes each word:
ThisShouldBePascalCase
Camel Casing - is similiar to pascal case but the first word is not capitalized:
thisShouldBeCamelCase
You can read some history here
UPDATE: Change the camel case image after reading the comments.
回答2:
Pascal is a persons name... a persons name always starts capitalized, whereas 'camel' is just a noun and thus, unless the start of a sentence, is always lowercased.
回答3:
camel case - first letter of first word lower case, and first letter of every word, after that should be Upper Case.
Examples:
- camelCase
- camelCaseLetter
pascal case - first letter of every word should be upper case.
Examples:
- PascalCase
- PascalCaseLetter
回答4:
Pascal Case: in Pascal case every word of each letter should be capital like MossawarHussain
Camel case: As the name show it follow the camel structure of word like mossawarHussain
Difference:
Pascal is a subset of Camel case. The first letter of Pascal is capital and first letter of the camel is small that is the major difference between these two cases.
回答5:
In camel case first letter of first word lower case, and first letter of every word, after that should be Upper Case.
Ex: userName userFullName
In pascal case first letter of every word should be upper case.
Ex: UserName UserFullName
回答6:
In camel Case there are two types one is Upper Camel Case and other one is the lower Camel Case. Upper Camel Case, a.k.a Pascal Case. Camel cases usually used in codings. In React Best Practices, You can use Upper Camel Case. https://towardsdatascience.com/react-best-practices-804def6d5215
{
"UpperCamelCase or PascalCase": "ThisIsAnExample. thisIsNotAnExample."
"lower Camel Case": "thisIsAnExample. ThisIsNotAnExample."
}
回答7:
For anyone looking, here's a Python module that'll do either case: to-camel-case
pip install to-camel-case
import to_camel_case
to_camel_case('snake_case') # snakeCase
to_camel_case('snake_case', pascal=True) # SnakeCase
Full disclosure: I'm the author
来源:https://stackoverflow.com/questions/41768733/camel-case-and-pascal-case-mistake