更新时间:2022-05-07 GMT+08:00
命名
本章节介绍脚本中函数、结构体、参数等的命名要求。
所有的名称定义要能体现其作用,避免使用缩写(专有名词除外)。
- 脚本采用小驼峰命名,例如createDeviceInstance。
- 结构体(struct)采用大驼峰命名,例如QueryPaymentResult。
- 结构体内的字段采用小驼峰命名,例如customerName 。
- 类、枚举值和接口采用大驼峰命名。
class Comments {...} interface Console {...} enum Direction { Up = 1, Down, Left, Right}
- 函数采用小驼峰命名。
addOfferingAssociatePriceAndStock(input: Input): Output {...}
- 属性或变量采用小驼峰命名。
class Comments { userId: String; content: String; } let oneComments = newComments();
- 变量为单数时,命名包含对象名称,如level1Catalog、level2Catalog。
- 变量为复数时,命名包含集合名称,如attributeRelationRuleList。
父主题: 脚本开发规范
