Skip to content
無瑕的程式碼 Clean Code
Share
Explore

icon picker
常見的命名法

現代軟體開發 基本都是採用下列命名方法:

1、駝峰式(Camel Case)命名法

📍 小駝峰 (lowerCamelCase)

開頭一定小寫,其餘單字首字母大寫
常用在 區域變數(Local Variables)的宣告
例如:
firstName = "JJJJ";
userPhone = "123456789"

📍 大駝峰 (UpperCamelCase)

又稱 Pascal case,跟小駝峰的差別在於首字母一定大寫
很常套用在 類別(Class)方法(Method) 的命名
例如:
export class QuestionComponent {

private QuestionDetail():void {
......
}
}

2、蛇式(snake_case)

所有單字間的變換都以下底線來連接,又分為 小蛇式 與 大蛇式
以我們專案來說,「路由路徑」就是典型的例子
例如:
export const routeConstant = {
/** 登入須知頁 */
LOGIN_GUIDE: 'login-guide'
}
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.