更新时间:2023-03-03 GMT+08:00
分享

命名

脚本(简称Script)用于开发原子功能API。脚本不能被外部直接通过Rest接口调用,只能用于业务编排。对脚本要进行合理的抽象和封装,以便在不同的服务编排中复用。本章节介绍脚本中函数、结构体、参数等的命名要求。

所有的名称定义要能体现其作用,避免使用缩写(专有名词除外)。

  • 脚本采用小驼峰命名,例如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。
分享:

    相关文档

    相关产品