介紹幾種常見的命名規則


  • Camel Case
    因為單字的開頭大寫,看起來像是駝峰 XD
    可以進一步細分為 upper camel case (BrowserStack) 與 lower camel case (iPhone),差別在於開頭第一個字是否為大寫.
    另外,因為 upper camel case 又稱為 Pascal Case,因此有部分人泛指 Camel Caselower 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

參考資料:

Leave a Reply