Skip to content

Commit

Permalink
Update codingrules.adoc
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm authored Dec 1, 2024
1 parent 9d6c8f1 commit 30f04ff
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions docs/dev/modules/reference/pages/codingrules.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ public:
private:
//! member
int member;
int M_member;
//! another member
int member_;
};
//! the function
Expand Down Expand Up @@ -231,14 +233,16 @@ class MeshAdaptation {};
----

* Non-static data members name of structures and classes always start with `M_` . M stands for Member. The rational behind this is for example :
* Non-static data members name of structures and classes always start with `M_` . M stands for Member, or adding `_` at the end of the member name. The rational behind this is for example :
** to be able to immediately see that the data is a member of a class or a struct
** to easily search and query-replace

[source,cpp]
----
// Wong
class meshAdaptation { std::vector directions; };
// Wrong
// Correct
class meshAdaptation { std::vector directions_; };
// Correct
Expand All @@ -252,6 +256,8 @@ class MeshAdaptation { std::vector M_directions; };

[source,cpp]
----
// Wrong
class meshAdaptation { static std::vector directions; };
// Wrong
class meshAdaptation { static std::vector directions_; };
Expand Down Expand Up @@ -356,7 +362,19 @@ if (address.isEmpty() || !isValid() || !codec)
{
return false;
}
else
{
return true;
}
// Wrong
if (address.isEmpty() || !isValid() || !codec) {
return false;
}
else {
return truel
}
----

* Exception 2: Use braces also in if-then-else blocks where either the if-code or the else-code covers several lines
Expand Down

0 comments on commit 30f04ff

Please sign in to comment.