This is the C + + believer's Moses 10 precepts, although the Ten Commandments, in fact there are 14, but these 14 are worth engraved on the edge of the display for C + + programmers to worship every day. I will engrave it in my blog, engraved in my memory, until they become part of my mind.
No. 0: Don't stick to the details (understand what should not be standardized)
Indent: Do not have to specify how to indent, each person to follow a favorite rule.
• President: Today there is no much need to limit the 80 characters, of course, the more conducive to reading the better.
• Naming: Don't be too harsh, except that macros should all be capitalized, as long as you follow some kind of acceptable style. There are 2 common styles, one is the hyphen connection all lowercase words, the other is the word first letter capitalization. If you need to use a variety of third-party libraries, it is almost impossible to maintain a style. Consistent within a certain range, the goal is to make reading easier.
• Note: Do not specify the format of the annotation. However, it's a good idea to use annotations with Doxygen syntax, and I've been using Doxygen to produce documents.
• Hungarian notation: I am glad that I have found an ally who supports me for what I dislike. Using a little trick to express a type in the C + + language is unhelpful, and C + + doesn't need it at all, it only leads to chaos.
• Single-entry single export: in the C + + world, which supports exceptions and deterministic deconstruction, this is superfluous.
Here, there is a clear-cut objection to two things: the Hungarian notation and the principle of single entry.
1th: Cleanly compile at high warning level
Turn the compiler's warning level up to maximum and silently generate results. For a man who sees the warning as nothing, close the door! Put the dog! Also, do not easily turn off compiler warnings in the source code.
• For Third-party libraries, block around the included files.
• Parameter not used: This parameter name is not provided.
• Unused variable: You can insert an expression for that variable. This is an idiomatic method, it will be more used.