diff options
author | Sage Weil <sage@newdream.net> | 2011-07-14 10:49:33 -0700 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-07-14 10:49:33 -0700 |
commit | bc6eb105864a60cc9519d12d4eb9ad5d202d2ee9 (patch) | |
tree | 65c4d19384482fd1e0792c32d70b71b034148944 | |
parent | f29b9bd7dee079553675219a592a3532cf42401e (diff) | |
download | ceph-bc6eb105864a60cc9519d12d4eb9ad5d202d2ee9.tar.gz |
CodingStyle: final decisions?
- _d suffix for naked struct/class types (not _t!)
- m_ prefix for class members
- prefer braces for single line ifs.
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | CodingStyle | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/CodingStyle b/CodingStyle index da529c64b00..c4906bc3817 100644 --- a/CodingStyle +++ b/CodingStyle @@ -28,17 +28,31 @@ by section. Google uses CamelCaps for all type names. We use two naming schemes: - - for structs (simple data containers), lower case with _t suffix: - struct my_type_t { + - for naked structs (simple data containers), lower case with _d + suffix ('d' for data). Not _t, because that means typdef. + + struct my_type_d { int a, b; - my_type_t() : a(0), b(0) {} + my_type_d() : a(0), b(0) {} }; - - for regular classes, CamelCaps, private: section, etc. + + - for full-blown classes, CamelCaps, private: section, accessors, + probably not copyable, etc. * Naming > Variable Names: - Google uses _ suffix for class members. We haven't up until now. Should we? + Google uses _ suffix for class members. That's ugly. We'll use + a m_ prefix, like so: + class Foo { + public: + int get_foo() const { return m_foo; } + void set_foo(int foo) { m_foo = foo; } + + private: + int m_foo; + }; + * Naming > Constant Names: Google uses kSomeThing for constants. We prefer SOME_THING. @@ -69,7 +83,11 @@ the code origin isn't reflected by the git history. - Always use newline following if: if (foo) - bar; // okay + bar; // okay, but discouraged... + + if (foo) { + bar; // this is better! + } if (foo) bar; // no, usually harder to parse visually |