正在加载图片...
软件编程规范总则 2注释 12-5:边写代码边注释,修改代码同时修改相应的注释,以保证注释与代码的一致性。不再有 用的注释要删除 2-6:注释的内容要清楚、明了,含义准确,防止注释二义性。 说明:错误的注释不但无益反而有害 规则2-7:避免在注释中使用缩写,特别是非常用缩写。 说明:在使用缩写时或之前,应对缩写进行必要的说明。 12-8:注释应与其描述的代码相近,对代码的注释应放在其上方或右方(对单条语句的注释) 相邻位置,不可放在下面,如放于上方则需与其上面的代码用空行隔开 示例:如下例子不符合规范。 例1: /* get replicate sub system index and net indicator * repssn ind ssn data[index]. repssn index repssn ni ssn data [index]. ni 例 repssn ind ssn data[index]. reps sn indexi ssn ni ssn data [index]. nii / get replicate sub system index and net indicator * 应如下书写 /* get replicate sub system index and net indicator * ind =ssn data[index]. reps sn index repssn ni ssn data [index]n 12-9:对于所有有物理含义的变量、常量,如果其命名不是充分自注释的,在声明时都必须加 以注释,说明其物理含义。变量、常量、宏的注释应放在其上方相邻位置或右方。 / active statistic tas k number * de fine MAX ACT TASK NUMBER 1000 仅供内部使用软件编程规范总则 2 注释 仅供内部使用 11 ¹2-5:边写代码边注释,修改代码同时修改相应的注释,以保证注释与代码的一致性。不再有 用的注释要删除。 ¹2-6:注释的内容要清楚、明了,含义准确,防止注释二义性。 说明:错误的注释不但无益反而有害。 规则2-7:避免在注释中使用缩写,特别是非常用缩写。 说明:在使用缩写时或之前,应对缩写进行必要的说明。 ¹2-8:注释应与其描述的代码相近,对代码的注释应放在其上方或右方(对单条语句的注释) 相邻位置,不可放在下面,如放于上方则需与其上面的代码用空行隔开。 示例:如下例子不符合规范。 例 1: /* get replicate sub system index and net indicator */ repssn_ind = ssn_data[index].repssn_index; repssn_ni = ssn_data[index].ni; 例 2: repssn_ind = ssn_data[index].repssn_index; repssn_ni = ssn_data[index].ni; /* get replicate sub system index and net indicator */ 应如下书写 /* get replicate sub system index and net indicator */ repssn_ind = ssn_data[index].repssn_index; repssn_ni = ssn_data[index].ni; ¹2-9:对于所有有物理含义的变量、常量,如果其命名不是充分自注释的,在声明时都必须加 以注释,说明其物理含义。变量、常量、宏的注释应放在其上方相邻位置或右方。 示例: /* active statistic task number */ #define MAX_ACT_TASK_NUMBER 1000
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有