学会思考
刻意练习

1.遵循C++规定的变量及函数命名方法;

2.原则:简单,易于理解;

以下是一些例子,可以作为参考:

//bad examples:
int ccount;//Nobody knows what a ccount is.
int i;//Generally bad unless use is trivial or temporary, such as loop variables.
int _count;//don't start variable names with underscore.
int data;//What kind of data?
int value1,value2;//Can be hard to differentiate between the two?
int x,y;//generally bad unless use is trivial, such as in trivial mathematical functions.

//good examples:
int customerCount;//clear what we're counting
int index;//okay if obvious what we're indexing
int totalScore;//good descriptive
int numberOfApples;//descriptive
int monstersKilled;//descriptive

 

posted on 2016-12-02 22:15  Worty  阅读(345)  评论(0编辑  收藏  举报