1 Star 0 Fork 32

FivePlus / QPerf

forked from pcd / QPerf 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
编码规范.md 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
pcd 提交于 2021-04-10 20:56 . :pencli: 文档拆分(test)

:triangular_flag_on_post:命名

  • :pushpin: 文件名
    所有源代码文件均使用全小写命名,源码文件的名称与文件中的类名称一致。
  • :pushpin: 类命名
    大写开头,遵从驼峰式命名法,使用英文名词对需要缩写的单词,不得超过三个连续的大写字母。
  • :pushpin: 类方法命名
    小写开头,遵从驼峰式命名法。
  • :pushpin: 类成员命名
    类成员使用m_开头,紧接着的单词以小写开头,并遵从驼峰式命名法。
  • :pushpin: 属性命名
    获取属性名称以对应的成员名称为准(去掉m_开头), 设置属性加入前置set,并接属性大写开头。
  • :pushpin: 局部变量命名
    局部变量以小写开头,遵从驼峰式命名法。
  • :pushpin: 枚举命名
    枚举中的成员以枚举类型的缩写开头。并与实际名称以_连接。 比如OptionType类型中的CmdPort。命名为Opt_CmdPort。

:triangular_flag_on_post:注释

注释主要有区块注释/**/ 和行注释// ,应用于类、方法、成员等。

  • :pencil2: 类注释
    例子:
/**
 * @brief The CommandParser class
 * 解析命令参数。
 */ 
  • :pencil2: 方法注释
    正常情况下,所有的方法都需要注释,在方法为被重载的方法时,可不注释。注释例子:
/**
* @brief cmdIPTuple 获取命令的IP五元组。
* @param dest 输出参数。
* @return 成功返回true。
*/
  • :pencil2: 成员注释
    例子:
    int m_sampling;   //数据采样率
    int m_allowErrorCode;    //允许数据包容错大小
    QTime m_startTime;  //启动时间
    qint64 m_totalSampleCount; //读取到的总数据大小 

:triangular_flag_on_post:代码格式

  • :pencil2: if 条件
if(condition)
{
  dosth..
}
  • :pencil2: while 循环
while(condition)
{
dosth...
}

do{
 dosth...
}while(condtion)

:triangular_flag_on_post:文件编码

所有代码文件采用utf-8 带BOM头格式保存

:triangular_flag_on_post:其它规范

  • :pencil2:类的代码行数限定 500行以内
  • :pencil2:类方法代码行数限定 50行以内
  • :pencil2:类的继承层次不超过3层
  • :pencil2:while if-else switch-case 等嵌套层次不能超过3层
C++
1
https://gitee.com/Five5Plus/qperf.git
git@gitee.com:Five5Plus/qperf.git
Five5Plus
qperf
QPerf
master

搜索帮助