IMO, it’s really bad practice to use it, unless it’s really necessary.
The code should include what you need - nothing more. This does not mean that you cannot (for example) implement convenient functions that are not strictly necessary for using the software, but that the code should include exactly what is needed to implement the functions.
I will add that, in my opinion, the use of prefixes, such as m
or m_
for member variables, belongs to the same category: simple noise, which contributes nothing to real understanding.
In any case, the sense of need for such added noise tends to indicate that the code is simply not very well designed. There are several cases (for example, parameters passed to the constructor) where it is reasonable to have some confusion as to what the internal value is and not the value coming from outside, but this is an exception, not a rule. Since they are an exception, emergency measures to prevent / avoid ambiguity should also be limited to them, for example, the init
prefix, which will be systematic, but still meaningful:
class X { int x, y, z; public: X(int init_x, int init_y, int init_z) : x(init_x), y(init_y), z(init_z) {} };
source share