介紹幾種常見的命名規則
- Camel Case
由來是單字的開頭大寫,看起來像是駝峰一樣 可以進一步細分為 upper camel case (BrowserStack
) 與 lower camel case (iPhone
),差別在於開頭第一個字是否為大寫. 備註:upper camel case 又稱為 Pascal Case,因此部分人泛指 Camel Case 為 lower camel case
Camel case is named after the “hump” of its protruding capital letter, similar to the hump of common camels.
- Snake Case
簡單來說是用_
來分隔單字的命名規則,像是fibonacci_sequence
起源來自 Ruby 社群的一句討論
BTW…what *do* you call that naming style? snake_case? That’s what I’ll call it until someone corrects me.
- Kebab Case
簡單來說是用-
來分隔單字的命名規則,像是fibonacci-sequence
有許多另外的別稱spinal-case
,Train-Case
,Lisp-case
參考資料: