源自一句话
There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors.
这里我所说的就是关于命名约束的问题
-
常见命名类型:
camelCase
Example camelCaseVar
.
snake_case
Example snake_case_var
.
kebab-case
Example kebab-case-var
.
PascalCase
Example PascalCaseVar
.
UPPER_CASE_SNAKE_CASE
Example UPPER_CASE_SNAKE_CASE_VAR
.
如何选择?
其实我们所接触的程序,Java,Python,Go,C系列,Js中都有自己的命名规范,遵守开发规范,能最大程度的提高自己的开发能力
简单比较下
Case Type | Example |
---|---|
Original Variable as String | some awesome var |
Camel Case | someAwesomeVar |
Snake Case | some_awesome_var |
Kebab Case | some-awesome-var |
Pascal Case | SomeAwesomeVar |
Upper Case Snake Case | SOME_AWESOME_VAR |