Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document our coding style.

  • Loading branch information...
commit 79b1ca3c25f088fa76ac544f9d270fcd53311222 1 parent 74d4d13
@kr authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 STYLE
View
57 STYLE
@@ -0,0 +1,57 @@
+Here is a description of the prevailing coding style in beanstalkd. Overall,
+our style is pretty close to K&R style, but there are a few differences.
+
+Really the only important rule is to follow the style of existing code. This
+document is just to help you out by describing some aspects of that style
+explicitly.
+
+If in doubt, ask the list at beanstalk-talk@googlegroups.com.
+
+ * Use no tabs, only spaces.
+
+ * Limit lines to 80 columns.
+
+ * Indent by four spaces.
+
+ * Do not include trailing spaces.
+
+ * Surround binary operators (indluding boolean, arithmetic, and assignment)
+ with a space on each side.
+
+ * Put the name of a function definition on the line after the function's
+ return type.
+
+ * Put the opening curly brace of a function on a line by itself in the first
+ column.
+
+ * Put a blank line after a block of declarations.
+
+ * Put a blank line after each function.
+
+ * Put the opening curly brace of an "if" or "for" statement on the same line
+ as the "if" or "for" keyword.
+
+ * If the body of an "if" or "for" statement fits on the same line, you can
+ leave off the braces. For example, write
+
+ if (x) return;
+
+ instead of
+
+ if (x) {
+ return;
+ }
+
+ However, always include the braces when there is an "else" clause.
+
+ * Put the "else" keyword on the same line as the preceding closing curly
+ brace.
+
+ * When testing pointers, don't compare them to NULL; instead test the value
+ directly. For example, write
+
+ if (x && !y)
+
+ instead of
+
+ if (x != NULL && y == NULL)
Please sign in to comment.
Something went wrong with that request. Please try again.