What are the different kinds of cases?

纵然是瞬间 提交于 2019-12-02 17:01:24
Nils von Barth

Names are either generic, after a language, or colorful; most don’t have a standard name outside of a specific community.

There are many names for these naming conventions (names for names!); see Naming convention: Multiple-word identifiers, particularly for CamelCase (UpperCamelCase, lowerCamelCase). However, many don’t have a standard name. Consider the Python style guide PEP 0008 – it calls them by generic names like “lower_case_with_underscores”.

One convention is to name after a well-known use. This results in:

  • PascalCase
  • MACRO_CASE (C preprocessor macros)

…and suggests these names, which are not widely used:

  • c_case (used in K&R and in the standard library, like size_t)
  • lisp-case, css-case
  • COBOL-CASE

Alternatively, there are illustrative names, of which the best established is CamelCase. snake_case is more recent (2004), but is now well-established. kebab-case is yet more recent and still not established, and may have originated on Stack Overflow! (What's the name for dash-separated case?) There are many more colorful suggestions, like caterpillar_case, Train-case, caravan-case, etc.

  • Flat case: myvariable
  • Kebab case: my-variable (this is the most famous. Other names include: caterpillar case, dash case, hyphen case, lisp case, spinal case and css-case)
  • Camel case: myVariable
  • Pascal case: MyVariable (other names: capital camel case)
  • Snake case: my_variable (other names: c case)
  • Macro case: MY_VARIABLE (other names: upper case)
  • Cobol case: COBOL-CASE (other names: Train case)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!