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
Last revisionBoth sides next revision
dev:dg_code_style_guide [2017/09/13 08:39] devadev:dg_code_style_guide [2017/09/13 08:58] – [Curly Braces] deva
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 132: Line 132:
 Use [[http://www.emacswiki.org/emacs/SmartTabs|"SmartTabs"]], ie. tabs for indentation and spaces for alignment. Use [[http://www.emacswiki.org/emacs/SmartTabs|"SmartTabs"]], ie. tabs for indentation and spaces for alignment.
  
-Tab-width is irrelevant as it is up to the editor to show them in whatever manner the programmer likes them.+<code> 
 +--->// Tab size: 4             ->// Tab size: 2 
 +--->if(foo)                    ->if(foo) 
 +--->                         ->{ 
 +--->--->char q[2][2] = {0, 1,  ->->char q[2][2] = {0, 1,  // "0" and "2" 
 +--->--->................2, 3}; ->->................2, 3}; // remain aligned 
 +--->                         ->} 
 +</code> 
 + 
 +With smart-tabs the tab-width doesn't affect the way the code is 
 +aligned which makes it up to the individual developer to choose the 
 +tab-width of his or her taste.
  
 Download [[https://raw.githubusercontent.com/jcsalomon/smarttabs/master/smart-tabs-mode.el|smart-tabs-mode.el]] and [[https://elpa.gnu.org/packages/cl-lib.html|cl-lib]] into the ''.emacs.d/lisp'' folder and add the following lines to the ''.emacs'' file: Download [[https://raw.githubusercontent.com/jcsalomon/smarttabs/master/smart-tabs-mode.el|smart-tabs-mode.el]] and [[https://elpa.gnu.org/packages/cl-lib.html|cl-lib]] into the ''.emacs.d/lisp'' folder and add the following lines to the ''.emacs'' file:
Line 204: 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 211: 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 223: Line 234:
 //defines//: //defines//:
 <code c++> <code c++>
-#define ALL_UPPERCASE_WITH_UNDERSCORES 42+#define SHOUTING_SNAKE_CASE 42
 </code> </code>
  
Line 252: 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.txt · Last modified: 2017/09/13 09:04 by deva
Trace:
GNU Free Documentation License 1.3
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0