Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:dg_code_style_guide [2017/09/13 08:42] – [Indentation] devadev:dg_code_style_guide [2017/09/13 09:04] (current) – [DrumGizmo Code Styleguide] deva
Line 3: Line 3:
 | **//Code is written once by one person but read many times by many people.//** | | **//Code is written once by one person but read many times by many people.//** |
  
-What this essentially boils down to is; don't make syntactic short-cuts that makes it easier to write the code if it makes it harder to read the the code.+What this essentially boils down to is; don't make syntactic short-cuts that makes it easier to write the code if it makes it harder to read the code.
  
 Always write comments to logical blocks in the code that explains for example what a for loop does or how a couple of function calls interact. Always write comments to logical blocks in the code that explains for example what a for loop does or how a couple of function calls interact.
Line 15: Line 15:
 =====Curly Braces===== =====Curly Braces=====
 Use [[https://en.wikipedia.org/wiki/Indent_style#Allman_style|BSD/Allman style]]. Use [[https://en.wikipedia.org/wiki/Indent_style#Allman_style|BSD/Allman style]].
-This basically boils down to 'curly braces always on a new line' with the only exception being switch statements (see later section) as this:+This basically boils down to 'curly braces always on a new line':
 <code c++> <code c++>
 namespace Foo namespace Foo
Line 133: Line 133:
  
 <code> <code>
---->// Tab size: 4              ->// Tab size: 2 +--->// Tab size: 4             ->// Tab size: 2 
---->if(foo)                     ->if(foo) +--->if(foo)                    ->if(foo) 
---->                          ->{ +--->                         ->{ 
---->--->char q[2][2] = {0, 1,   ->->char q[2][2] = {0, 1,   // "0" and "2" +--->--->char q[2][2] = {0, 1,  ->->char q[2][2] = {0, 1,  // "0" and "2" 
---->--->................2, 3};  ->->................2, 3};  // remain aligned +--->--->................2, 3}; ->->................2, 3}; // remain aligned 
---->                          ->}+--->                         ->}
 </code> </code>
  
Line 215: Line 215:
 The following naming schemes apply:\\ The following naming schemes apply:\\
  
-//classes//:+//classes and structs//:
 <code c++> <code c++>
 class UpperCaseCamelCase class UpperCaseCamelCase
Line 222: Line 222:
 </code> </code>
  
-//methods//:+//methods and functions//:
 <code c++> <code c++>
 void lowerCaseCamelCase() void lowerCaseCamelCase()
 </code> </code>
  
-//variables//:+//variables and members//:
 <code c++> <code c++>
 int lower_case_snake_case = 42; int lower_case_snake_case = 42;
Line 234: Line 234:
 //defines//: //defines//:
 <code c++> <code c++>
-#define ALL_UPPERCASE_WITH_UNDERSCORES 42+#define SHOUTING_SNAKE_CASE 42
 </code> </code>
  
Line 263: Line 263:
   //! This is a method.   //! This is a method.
   //! \param foo The foo argument is an integer.   //! \param foo The foo argument is an integer.
-  //! \param bar The bar argument is a boolan.+  //! \param bar The bar argument is a boolean.
   //! \return This method returns a float.   //! \return This method returns a float.
   float method(int foo, bool bar);   float method(int foo, bool bar);
dev/dg_code_style_guide.1505284943.txt.gz · Last modified: 2017/09/13 08:42 by deva
Trace:
GNU Free Documentation License 1.3
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0