You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variables use snake_case since they tend to be shorter than functions.
Why not the m prefix?
We need to use m_ for snake_case and m for camelCase.
m_ and m are inconsistent.
m_snake_case is longer than snake_case_.
Class Members and non-members (and struct members) are distinguished by the _ suffix, which is similar to Google's C++ Coding Style.
The difference is that we apply this pattern to methods as well.
Only class members have the _ suffix because they have methods, and within methods, variables/functions and members are hard to be distinguished. (Structs won't have methods. => this is different from Google's)
This naming convention can be problematic when we want to refer to a member variable via methods:
class A {
int some_thing_;
public:
int someThing_(); // ok, but depending on the variable name, it might be difficult to read the connection?
// Also, somewhat annoying when we want to grep the original variable?
int getSome_thing_(); // violates camelCase_
int get_some_thing_(); // violates camelCase_
Idea
PascalCase
PascalCase
snake_case
snake_case_
camelCase
camelCase_
Reasoning/Explanation
snake_case
since they tend to be shorter than functions.m
prefix?m_
forsnake_case
andm
forcamelCase
.m_
andm
are inconsistent.m_snake_case
is longer thansnake_case_
._
suffix, which is similar to Google's C++ Coding Style._
suffix because they have methods, and within methods, variables/functions and members are hard to be distinguished. (Structs won't have methods. => this is different from Google's)Steps to apply this new policy
Class (non-struct) Methods
naming convention.Class (non-struct) Member Variables
naming convention.Variables
naming convention.See also
The text was updated successfully, but these errors were encountered: