Quote:Original post by Promit
Quote:Original post by eedok
isn't prefixing a bad thing?
Type based prefixing is a terrible thing. Scope based prefixing, however, is an entirely different matter, however, and remains in the .NET Naming Guidelines. Specifically, private and protected members of a class should be prefixed with a single underscore, e.g. int _privateData;. I use the same convention myself, although with m_ for largely historical (and now consistency) reasons.
Actually, prefixing with an underscare is a very bad idea, since many identifiers with leadings underscores are technically reserved for use by the implementions, as are
any identifiers with double leading underscores.
What you'll see in modern C++ books a fair bit is training underscores. Also, the "Writing Unmaintainable Code" essay makes the very good point that m_ could just as easily mean method :P ( Not to mention that STL naming conventions use lowercase_with_underscores and no abbreviations )
Agreed, BTW, about type-based prefixing, at least in strongly-typed languages. Sense the compiler prevents you from modifying a const variable, for example, you don't need a c prefix. As for purpose-based prefixing, it's acceptable, although it's better if it's done with just a different type so that the compiler enforces it.
Oh, and you should be using a better variable name than "d" ;)