学习日志—类型和声明—advice

来源:互联网 发布:多迪php培训 编辑:程序博客网 时间:2024/06/07 22:21

[1]Keep scopes small.

 

[2]Don't use the same name in both a scope and  an enclosing  scope.

 

[3]Declare one name (only) per declaration.

 

[4]Keep common and local names short, and uncommon and nolocal names longer;

 

[5]Avoid similar-looking names;

 

[6]Maintain a consistent naming style;

 

[7]Choose names carefully to reflect meaning rather than implementation;

 

[8]Use a typedef to define a meaningful  name for a built-in type in case in which the built-in type used to represent a value might change;

 

[9]Remember that every declaration must specify a type (there is no "implicit int";

 

[10]Avoid unnecessary assumptions about the numeric value of characters;

 

[11]Avoid unnecessary assumptions about the size of integers;

 

[12]Avoid unnucessary assumptions about the range of floating-point types;

 

[13]Perfer a plain int over a short int or long int ;

 

[14]Perfer double over a float or long double;

 

[15]Perfer plain char over signed char and unsigned char;

 

[16]Avoid making unnecessary assumptions about the sizes of objects;

 

[17]Avoid unsigned arithmetic;

 

[18]View signed to unsigned and unsigned to signed conversions with suspicion;

 

[19]View floating-point to integer conversions with suspicion;

 

[20]View conversions to a smaller type,such as int to char ,with suspicion;