Skip to content
Snippets Groups Projects
Commit 35d3be77 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: fix spelling, backslashes etc. in codingStyleGuide.org

- now passes through LaTeX with fewer complaints.

- added note about braces for 'case' statements.

- could not formulate a sensible rule about when return statements
  need parentheses and when not.

- did not update codingStyleGuide.pdf ... I don't even know if it
  should be part of the git repo at all
parent 824df2c3
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
#+TITLE: OpenFOAM C++ style guide #+TITLE: OpenFOAM C++ style guide
#+AUTHOR: OpenCFD Ltd. #+AUTHOR: OpenCFD Ltd.
#+DATE: May 2010 #+DATE: June 2010
#+LINK: http://www.opencfd.co.uk #+LINK: http://www.opencfd.co.uk
#+OPTIONS: author:nil ^:{} #+OPTIONS: author:nil ^:{}
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
+ The normal indentation is 4 spaces per logical level. + The normal indentation is 4 spaces per logical level.
+ Use spaces for indentation, not tab characters. + Use spaces for indentation, not tab characters.
+ Avoid trailing whitespace. + Avoid trailing whitespace.
+ The body of control statements (eg, =if=, =else=, =while=, etc). + The body of control statements (eg, =if=, =else=, =while=, etc). is
always delineated with brace brackets. A possible exception can be always delineated with brace brackets. A possible exception can be
made with =break= or =continue= as part of a control structure. made in conjunction with =break= or =continue= as part of a control
structure.
+ The body of =case= statements is usually delineated with brace brackets.
+ A fall-through =case= should be commented as such.
+ stream output + stream output
+ =<<= is always four characters after the start of the stream, + =<<= is always four characters after the start of the stream,
...@@ -132,22 +135,25 @@ ...@@ -132,22 +135,25 @@
+ Use two empty lines between functions + Use two empty lines between functions
*** Coding Practice *** Coding Practice
+ passing data as arguments or return + passing data as arguments or return values.
Pass bool, label and scalar as copy, anything larger by reference. + Pass bool, label and scalar as copy, anything larger by reference.
+ const + const
Use everywhere it is applicable. + Use everywhere it is applicable.
+ variable initialisation using = + variable initialisation using
#+BEGIN_EXAMPLE
: const className& variableName = otherClass.data(); const className& variableName = otherClass.data();
#+END_EXAMPLE
NOT NOT
: const className& variableName(otherClass.data()); #+BEGIN_EXAMPLE
const className& variableName(otherClass.data());
#+END_EXAMPLE
+ virtual functions + virtual functions
If a class is virtual - make all derived classes virtual. + If a class is virtual, make all derived classes virtual.
*** Conditional Statements *** Conditional Statements
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
...@@ -169,7 +175,7 @@ ...@@ -169,7 +175,7 @@
} }
#+END_EXAMPLE #+END_EXAMPLE
NOT (no space between =if= and =(=) NOT (no space between =if= and =(= used)
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
if(condition) if(condition)
...@@ -201,7 +207,7 @@ ...@@ -201,7 +207,7 @@
} }
#+END_EXAMPLE #+END_EXAMPLE
NOT (no space between =for= and =(=) NOT this (no space between =for= and =(= used)
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
for(i = 0; i < maxI; i++) for(i = 0; i < maxI; i++)
...@@ -349,7 +355,7 @@ ...@@ -349,7 +355,7 @@
* (k + t); * (k + t);
#+END_EXAMPLE #+END_EXAMPLE
This is sometime more legible when surrounded by extra parentheses: This is sometimes more legible when surrounded by extra parentheses:
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
variableName = variableName =
...@@ -437,15 +443,15 @@ ...@@ -437,15 +443,15 @@
*** Doxygen Special Commands *** Doxygen Special Commands
Doxygen has a large number of special commands with a '\' prefix or a Doxygen has a large number of special commands with a =\= prefix or
(alternatively) an '@' prefix. (alternatively) an =@= prefix.
The '@' prefix form is recommended for most Doxygen specials, since it The =@= prefix form is recommended for most Doxygen specials, since it
has the advantage of standing out. It also happens to be what projects has the advantage of standing out. It also happens to be what projects
like gcc and VTK are using. like gcc and VTK are using.
The '\' prefix form, however, looks a bit better for the '\n' newline The =\= prefix form, however, looks a bit better for the =\n= newline
command and when escaping single characters - eg, '\@', '\<', '\>', etc. command and when escaping single characters - eg, =\@=, =\<=, =\>=, etc.
Since the filtering removes the leading 4 spaces within the blocks, the Since the filtering removes the leading 4 spaces within the blocks, the
Doxygen commmands can be inserted within the block without problems. Doxygen commmands can be inserted within the block without problems.
...@@ -514,7 +520,7 @@ ...@@ -514,7 +520,7 @@
#+END_EXAMPLE #+END_EXAMPLE
*** Documenting Typedefs and classes defined via macros *** Documenting typedefs and classes defined via macros
... not yet properly resolved ... not yet properly resolved
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment