命名规则:
命名原则以清晰为主, 不要太长
不要以_开始
命名中不要有__双下划线
以likethis例
类,结构,枚举:LikeThis
函数,变量:like_this
私有成员变量:like_this_
宏,常量:LIKE_THIS
定义指针或引用时, * 和 &靠在类型边上
全局变量:前缀用g_
文件名命名原则::
与类名命名相同
注释方式:
类: 摘要说明:/// Brief
变量尾部注释:///<
函数注释:
/// 功能说明.
///
/// @param 参数
/// @return 返回值
/// @see 参见
/// @note 注解
可在注释///后面加入如下的标志:
/struct to document a C-struct.
/union to document a union.
/enum to document an enumeration type.
/fn to document a function.
/var to document a variable or typedef or enum value.
/def to document a #define.
/typedef to document a type definition.
/file to document a file.
/namespace to document a namespace.
/package to document a Java package.
/interface to document an IDL interface.
常见编码规范:
避免重复代码
使用构造列表初始化成员,并确保所有的成员变量都初始化了
使用vector和string来代替数组和字符数组
DELETE对象后,要把指针=0
尽多的使用const
代码里尽量不使用魔术字
检查函数的入口参数的正确性, 返回值效率.
...
更多的编码规则参看<<c++编码规范>>
工程设置:
编译程序时将警告级别设为最高
编译参数设置中, 路径的设置必须用相对路径.
主工程与测试工程存放位置:
测试工程存放在被测试工程的目录下.比如:工程A, 有个test测试工程, 那么将
test放到A目录下.
cpp和h文件名应该小于14个字符
文件头(格式):
// ***************************************************************
// likeThis.h version: 1.0 ? date: 11/06/2007
// -------------------------------------------------------------
// author: 钟科军
// description:
// 基本的宏定义,库的导出,及删除
// -------------------------------------------------------------
// Copyright (C) 2007 - All Rights Reserved
// ***************************************************************
//
// ***************************************************************
版本控制系统:
版本控制系统将使用SVN, 提交的原则是代码编译通过, pclint检查无错,运行测
试通过.