variable names should use simple words if possible
不要起名字相同的函数
常量的定义,要把每个维度正交化,使用每个位来表示一个开关,或者几个位来表示一个组合
思维
如果在编码实现的过程中发现实际情况更加复杂,也不要直接改变思路,先实现原先想好的简单情况,在做拓展
类应该是 sans-IO 的,如果需要 IO,就写一些 load 函数,但是不要在构造函数中调用
Indent, spaces and newline
use spaces around + - * / = ==
use spaces only after ,;
one blank line between functions and two between classes
use \n as line endings
end file with a new line
always use 4 spaces to indent
always use K&R braces
Naming and variables
never use HN but prefix is for bool flags or methods e.g. is_open
use CamelCase for class name
use camelCase or snake_case for function, variable, method name, just be consistent
declare local variable as late as possible
use nullptr not NULL
Headers
header file should use *.hpp NOT *.h
always use #define guards
Reduce the number of #include files in header files. It will reduce build times. Instead, put include files in source code files and use forward declarations in header files. If a class in a header file does not need to know the size of a data member class or does not need to use the class's members then forward declare the class instead of including the file with #include. To avoid the need of a full class declaration, use references (or pointers) and forward declare the class.
Namespaces
never use using namespace std
其他
put a space after ifforwhile so that we know it's not invokation
never use if (someVar == true) or if (someVar == false), it's silly
Documnetation and comments
Documentations explain how to use code, and are for the users of your code
Comments explain why, and are for the maintainers of your code
use javadoc for documentations
use FIXBUGTODO???!!! to show different kinds of comments
日期与时间
Always use timezone-aware time or timestamp, never use local time string.
Reduce the number of #include files in header files. It will reduce build times. Instead, put include files in source code files and use forward declarations in header files. If a class in a header file does not need to know the size of a data member class or does not need to use the class's members then forward declare the class instead of including the file with #include. To avoid the need of a full class declaration, use references (or pointers) and forward declare the class.
Namespaces
never use using namespace std
Others
put a space after ifforwhile so that we know it's not invokation
never use if (someVar == true) or if (someVar == false), it's silly
Documnetation and comments
Documentations explain how to use code, and are for the users of your code
Comments explain why, and are for the maintainers of your code
use javadoc for documentations
use FIXBUGTODO???!!! to show different kinds of comments