[giimote commit] r190 - wiki

0 views
Skip to first unread message

codesite...@google.com

unread,
Feb 9, 2009, 1:52:29 PM2/9/09
to gii...@googlegroups.com
Author: leif902
Date: Mon Feb 9 09:09:02 2009
New Revision: 190

Added:
wiki/CodingStyles.wiki

Log:
Created wiki page through web user interface.

Added: wiki/CodingStyles.wiki
==============================================================================
--- (empty file)
+++ wiki/CodingStyles.wiki Mon Feb 9 09:09:02 2009
@@ -0,0 +1,96 @@
+#summary The coding styles used in GiiMote.
+#labels Phase-Design,Phase-Implementation,Type-Article
+
+= Introduction =
+
+This document gives a general outline and overview of the coding styles
used in GiiMote.
+
+Before sending in a patch or piece of code for review please refer to this
document and make sure your code complies with the recommendations set
forth in this document.
+
+
+= General Practices =
+ * Make sure your code does not throw warnings or errors.
+ * Ensure compatibility with 64-bit hardware.
+ * Use "interCaps" for symbols.
+ * Use "const" instead of a macro
+ for example:
+ {{{
+ #define BTN_PLUS 8 // This is wrong
+ const int BTN_PLUS = 8; // This is right
+ }}}
+ * Do not create null pointers.
+
+= Pointers =
+ * Cleanup the heap after yourself when declaring objects.
+
+= Aesthetics =
+ * Use proper .NET syntax (new style).
+ * Use attributes instead of methods when possible.
+ * Use Java-style constants, for example:
+ {{{
+ const int ERROR_NO_IR = -100;
+ }}}
+ * No white space at the end of a line
+ * Use the Allman indent style for control structures. For example:
+ {{{
+if (...)
+{
+ (...)
+}
+else
+{
+ (...)
+}
+
+while (...)
+{
+ (...)
+}
+
+do
+{
+ (...)
+} while (...);
+
+for (...; ...; ...)
+{
+ (...)
+}
+
+switch (...)
+{
+ case 1:
+ {
+ // When you need to declare a variable in a switch, put the block in
braces
+ int var;
+ }
+ break;
+ case 2:
+ (...)
+ break;
+ default:
+ break;
+}
+ }}}
+ * Declare methods outside of classes when classes become large.
+
+= Error Handling =
+ * Place try-catch statements around everything which interfaces directly
with the hardware or can return an error.
+ * Do not let errors break the logical progression of your code. Add
error checking as a separate entity in the code, do not incorporate it into
logic. For example:
+ {{{
+ // Do not do this:
+ if (noError(foobar) && foobar.boolean)
+ {
+ foobar.setBoolean(false);
+ }
+
+ // Do this:
+ if (isError(foobar)) return (foobar.lastError());
+ if (foobar.boolean)
+ {
+ foobar.setBoolean(false);
+ }
+ }}}
+
+
+|| Adapted from the "Mozilla Coding Style Guide" ||
\ No newline at end of file

Reply all
Reply to author
Forward
0 new messages