|
|
<ol><li><strong>Clang-format:</strong> ADIOS2 uses the clang-format tool to automatically enforce source code style and formatting rules. There are various ways to integrate the clang-format tool into your IDE / Code Editor depending on if you use Emacs, Vim, Eclipse, KDevelop, Microsoft Visual Studio, etc. that are a bit outside the scope of this document but a quick google search for "integrate clang-format" should point you in the right direction. Main points:
|
|
|
<ul><li>Lines no longer than 80 characters.</li>
|
|
|
<li>Always use braces { and }, even for 1 line <code>if</code> blocks.</li>
|
|
|
<li>Use 4 spaces for indentation.</li><li>However, you can always reformat the code manually by running:</li>
|
|
|
<li><pre style="border: 0;"><code>clang-format -i <a class="tc-tiddlylink tc-tiddlylink-missing" href="#SourceFile">SourceFile</a>.cpp <a class="tc-tiddlylink tc-tiddlylink-missing" href="#SourceFile">SourceFile</a>.h</code></pre></li></ul></li>
|
|
|
1. <strong>Clang-format:</strong> ADIOS2 uses the clang-format tool to automatically enforce source code style and formatting rules. There are various ways to integrate the clang-format tool into your IDE / Code Editor depending on if you use Emacs, Vim, Eclipse, KDevelop, Microsoft Visual Studio, etc. that are a bit outside the scope of this document but a quick google search for "integrate clang-format" should point you in the right direction. Main points:
|
|
|
* Lines no longer than 80 characters.
|
|
|
* Always use braces { and }, even for 1 line <code>if</code> blocks.
|
|
|
* Use 4 spaces for indentation.</li><li>However, you can always reformat the code manually by running:
|
|
|
```
|
|
|
clang-format -i SourceFile.cpp SourceFile.h
|
|
|
```
|
|
|
|
|
|
<li><strong>Naming:</strong> Use meaningful English words, well-known acronyms (MPI, XML, CFD, GMRES, etc.), or well-known short names (Config, Comm, 2D, 3D).
|
|
|
2. <strong>Naming:</strong> Use meaningful English words, well-known acronyms (MPI, XML, CFD, GMRES, etc.), or well-known short names (Config, Comm, 2D, 3D).
|
|
|
<ul>
|
|
|
<li>Examples: <strong>initialTime</strong> instead of <strong>tIni</strong> , or <strong>work</strong> instead of <strong>wrk</strong> </li>
|
|
|
<li>One Exception: when redefining long types with the <strong>using</strong> keyword reasonable mnemonics and short names are allowed, always document scope.
|
... | ... | @@ -16,7 +18,7 @@ using std::vector<std::vector<double>> = vDouble2D; |
|
|
</li>
|
|
|
</ul>
|
|
|
|
|
|
<li><strong>Avoid underscores:</strong> adds unnecessary length. Reserve it for prefixes of special cases (see class members and lambda functions). Use upper case letters instead.
|
|
|
3. <strong>Avoid underscores:</strong> adds unnecessary length. Reserve it for prefixes of special cases (see class members and lambda functions). Use upper case letters instead.
|
|
|
|
|
|
** Don't
|
|
|
|
... | ... | @@ -32,7 +34,7 @@ using std::vector<std::vector<double>> = vDouble2D; |
|
|
|
|
|
</li>
|
|
|
|
|
|
<li><strong>Using and typedef keywords:</strong> Prefer the keyword <strong>using</strong> over <strong>typedef</strong> for readability. Only rename very long complex or custom types, do not rename standard types ( int , double , std::vector ). Prefer including ADIOSTypes.h as it contains fixed types in the std:: namespace uint8_t, uint64_t .
|
|
|
4. <strong>Using and typedef keywords:</strong> Prefer the keyword <strong>using</strong> over <strong>typedef</strong> for readability. Only rename very long complex or custom types, do not rename standard types ( int , double , std::vector ). Prefer including ADIOSTypes.h as it contains fixed types in the std:: namespace uint8_t, uint64_t .
|
|
|
<ul>
|
|
|
<li> Don't
|
|
|
|
... | ... | @@ -47,5 +49,4 @@ using std::vector<std::vector<double>> = vDouble2D; |
|
|
```
|
|
|
</li>
|
|
|
</ul>
|
|
|
</li>
|
|
|
</ol> |
|
|
\ No newline at end of file |
|
|
|