Google uses CamelCaps for all type names. We use two naming schemes:
- - for naked structs (simple data containers), lower case with _d
- suffix ('d' for data). Not _t, because that means typdef.
+ - for naked structs (simple data containers), lower case with _t.
+ Yes, _t also means typedef. It's perhaps not ideal.
- struct my_type_d {
+ struct my_type_t {
int a, b;
- my_type_d() : a(0), b(0) {}
+ my_type_t() : a(0), b(0) {}
};
- for full-blown classes, CamelCaps, private: section, accessors,
* Naming > Variable Names:
Google uses _ suffix for class members. That's ugly. We'll use
- a m_ prefix, like so:
+ a m_ prefix, like so, or none at all.
class Foo {
public:
if ( foo ) { // no
- - Always use newline following if:
-
- if (foo)
- bar; // okay, but discouraged...
+ - Always use newline following if, and use braces:
if (foo) {
- bar; // this is better!
+ bar; // like this, even for a one-liner
}
- if (foo) bar; // no, usually harder to parse visually
+ if (foo)
+ bar; // no, usually harder to parse visually
+
+ if (foo) bar; // no
+
+ if (foo) { bar; } // definitely no