Camel case and Pascal case mistake

后端 未结 7 2030
我在风中等你
我在风中等你 2020-12-29 18:26

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 t

相关标签:
7条回答
  • 2020-12-29 18:56

    I could be wrong. PEP 8, for those writing in python, suggests otherwise.
    i.e. in python => CamelCase https://www.python.org/dev/peps/pep-0008/

    0 讨论(0)
  • 2020-12-29 18:58

    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.

    0 讨论(0)
  • 2020-12-29 18:58

    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

    0 讨论(0)
  • 2020-12-29 18:58

    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

    0 讨论(0)
  • 2020-12-29 19:12

    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
    0 讨论(0)
  • 2020-12-29 19:14

    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.

    0 讨论(0)
提交回复
热议问题