You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2014/09/09 18:58:56 UTC
git commit: Updated the Mesos C++ Style Guide.
Repository: mesos
Updated Branches:
refs/heads/master f57a1756c -> a82eff2f9
Updated the Mesos C++ Style Guide.
Review: https://reviews.apache.org/r/25274
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a82eff2f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a82eff2f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a82eff2f
Branch: refs/heads/master
Commit: a82eff2f9e71b9cac8b9d04c4b81ff8740c4ce58
Parents: f57a175
Author: Michael Park <mc...@gmail.com>
Authored: Tue Sep 9 09:55:47 2014 -0700
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Tue Sep 9 09:57:48 2014 -0700
----------------------------------------------------------------------
docs/mesos-c++-style-guide.md | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a82eff2f/docs/mesos-c++-style-guide.md
----------------------------------------------------------------------
diff --git a/docs/mesos-c++-style-guide.md b/docs/mesos-c++-style-guide.md
index a5f8df8..4381d24 100644
--- a/docs/mesos-c++-style-guide.md
+++ b/docs/mesos-c++-style-guide.md
@@ -12,10 +12,11 @@ The Mesos codebase follows the [Google C++ Style Guide](http://google-styleguide
* We use [lowerCamelCase](http://en.wikipedia.org/wiki/CamelCase#Variations_and_synonyms) for variable names (Google uses snake_case, and their class member variables have trailing underscores).
### Constant Names
-* We use lowerCamelCase for constant names (Google uses a `k` followed by mixed case, e.g. `kDaysInAWeek`).
+* We use [lowerCamelCase](http://en.wikipedia.org/wiki/CamelCase#Variations_and_synonyms) for constant names (Google uses a `k` followed by mixed case, e.g. `kDaysInAWeek`).
### Function Names
-* We use lowerCamelCase for function names (Google uses mixed case for regular functions; and their accessors and mutators match the name of the variable).
+* We use [lowerCamelCase](http://en.wikipedia.org/wiki/CamelCase#Variations_and_synonyms) for function names (Google uses mixed case for regular functions; and their accessors and mutators match the name of the variable).
+* Leave spaces around overloaded operators. e.g. `operator + (...);` rather than `operator+(...);`
## Strings
* Strings used in log and error messages should end without a period.
@@ -23,8 +24,18 @@ The Mesos codebase follows the [Google C++ Style Guide](http://google-styleguide
## Comments
* End each sentence with a period.
* At most 70 characters per line in comments.
+* For trailing comments, leave one space.
+
+## Breaks
+* Break before braces on function, class, struct and union definitions. (Google attaches braces to the surrounding context)
## Indentation
+
+### Class Format
+* Access modifiers are not indented (Google uses one space indentation).
+* Constructor initializers are indented by 2 spaces (Google indents by 4).
+
+### Function Definition/Invocation
* Newline when calling or defining a function: indent with 4 spaces.
* We do not follow Google's style of wrapping on the open parenthesis, the general goal is to reduce visual "jaggedness" in the code. Prefer (1), (4), (5), sometimes (3), never (2):
@@ -59,6 +70,7 @@ allocator->resourcesRecovered(
frameworkId, slaveId, resources, filters);
</pre>
+### Continuation
* Newline for an assignment statement: indent with 2 spaces.
<pre>
@@ -66,7 +78,7 @@ Try<Duration> failoverTimeout =
Duration::create(FrameworkInfo().failover_timeout());
</pre>
-## New Lines
+## Empty Lines
* 1 blank line at the end of the file.
* Elements outside classes (classes, structs, global functions, etc.) should be spaced apart by 2 blank lines.
* Elements inside classes (member variables and functions) should not be spaced apart by more than 1 blank line.