summaryrefslogtreecommitdiff
path: root/HACKING
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2009-12-02 23:27:56 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2009-12-02 23:27:56 +0200
commit8d638491861ef2ee0457db93c8d68d280c0c509f (patch)
tree63598e8516ea6168ad4afbb018205a9df9938453 /HACKING
parent10999ffdb5730d7acc3e8935b7283c125358153b (diff)
* HACKING: added some coding guidelines
Diffstat (limited to 'HACKING')
-rw-r--r--HACKING54
1 files changed, 54 insertions, 0 deletions
diff --git a/HACKING b/HACKING
new file mode 100644
index 0000000..cd6cfb5
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,54 @@
+* HACKING
+
+Here are some short guidelines for hacking on the 'mu' source code.
+
+** Coding style
+
+ For consistency and even more important, to keep things understandable, mu
+ follows the following rules:
+
+ 1. basic code layout is like in the Linux kernel coding style, with the '{'
+ on the same line as the statement, except for functions. Tabs/spaces
+ have width 8.
+
+ 2. lines must not exceed 80 characters
+
+ 3. functions must not exceed 30 lines (there may be rare exceptions), and
+ 30 lines is already pretty long.
+
+ 4. source files should not exceed 1000 lines
+
+ 5. a function's cyclomatic complexity should not exceed 10 (there may be
+ rare exceptions). You can test the cyclomatic complexity with the
+ pmccabe tool
+
+ 6. filenames have their components separated with dashes (e.g, 'mu-log.h')
+
+ 7. global functions have the prefix based on their module, e.g., mu-foo.h
+ declares a function of 'mu_foo_bar (int a);', mu-foo.c implements this.
+
+ 8. non-global functions *don't* have the module prefix, and are declared
+ static.
+
+ 9. functions have their return type on a separate line before the function
+ name
+
+ 10. in C code, variable-declarations are at the beginning of a block; in
+ principle, C++ follows that same guideline, unless for heavy yet
+ uncertain initializations following RAII.
+
+ 11. returned strings of type char* must be freed by the caller; if they are
+ not to be freed, 'const char*' should be used instead
+
+
+
+
+
+
+
+
+
+
+#+ Local Variables: ***
+#+ mode:org ***
+#+ End: ***