Skip to content

Commit 9042c08

Browse files
authored
Merge pull request #692 from sebproell/docs-coding-style
Update docs on naming conventions
2 parents 3ec5f5e + 2b352d7 commit 9042c08

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

doc/documentation/src/developer_guide/codingguidelines.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ in the future.
2525

2626
**New code should always follow the following guidelines. Touching old code is always a great opportunity to improve it with respect to these guidelines.**
2727

28+
.. _avoid-define-flags:
29+
2830
Avoid define flags
2931
^^^^^^^^^^^^^^^^^^
3032

@@ -69,8 +71,7 @@ In addition, the string-based lookup is not compile-time checked.
6971
Const-correctness
7072
^^^^^^^^^^^^^^^^^
7173

72-
Make new code const-correct and fix old code in that regard when working on it. Const-correctness is mainly relevant
73-
for function parameters and member functions.
74+
Make code const-correct. Const-correctness is mainly relevant for function parameters and member functions.
7475

7576
**Note:** The member fields of a struct or class should often not be ``const``, as this would prevent the struct or
7677
class from being moved or copied. Instead, use ``const`` member functions to access the fields in a ``const`` context.
@@ -91,15 +92,18 @@ See also `Enum.3 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#e
9192
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9293

9394
- **Namespaces** use CamelCase: ``LinAlg::``
94-
- **Class names** / **function** names / **enum types** use camel case, starting with a capital letter:
95-
``ClassToDoSomething / FunctionToPerformAnOperation()``
95+
- **class**, **struct** and **enum** types use CamelCase: ``ClassName``, ``StructName``, ``EnumName``
96+
- **Functions** use snake_case: ``function_with_descriptive_name()``
9697
- **Variables** and **enum values** use
9798

9899
- snake_case, i.e. all lower-case letters separated by underscores, e.g. ``variable_with_descriptive_name``
99100
- camelCase starting with a lower-case letter, e.g. ``variableWithDescriptiveName``
100101

101-
- **Class members** end with an underscore: ``variable_``
102-
- **Define flags** are in all caps: ``DEBUG``
102+
- **Private class members** end with an underscore: ``variable_``
103+
- **Define flags** are all CAPS: ``FOUR_C_ENABLE_ASSERTIONS`` (please :ref:`avoid define flags<avoid-define-flags>`)
104+
105+
The full specification of the naming convention is listed in the
106+
`.clang-tidy configuration file <https://github.com/4C-multiphysics/4C/blob/main/.clang-tidy>`_.
103107

104108
Variable names must not be just a single letter, because they are impossible to find in a global search operation.
105109
(Exception: loop indices such as i, j, but remember that even loop indices could/should have descriptive names.)

0 commit comments

Comments
 (0)