I'm programming C++ using the underscore naming style (as opposed to camel case) which is also used by the STL and boost. However, since both types and variables/functions are named all lower case, a member variable declaration as follows will lead to compiler errors (or at least trouble):
position position;
A member variable named position which is of type position. I don't know how else to name it: It's generally a position, but it is also the position of the object. In camel case, this would be fine with the compiler:
Position position;
But in C++ it causes problems. I don't want to switch to camel case, use Hungarian notation or add a trailing underscore because of that, so I'm wondering: Is it a good practice to name a member like a type anyways?
In C, it is pretty common to use cryptic one-letter variables for this:
int i;
But I find that a bit, well, cryptic:
position p;
Are there any rules of thumb for variable naming I can use to avoid this?
There are more examples in my code if you need something to work on:
mouse_over(entity entity) // Returns true if the mouse is over the entity
manager &manager; // A reference to the framework's manager
audio audio; // The audio subsystem
Edit:
I was curious to see if Bjarne Stroustrup himself has something to say on this issue. Apparently, he hasn't, but he suggests coding conventions that would work around my compiler problems:
For example, capitalize nonstandard library user-defined types and start nontypes with a lowercase letter
That'd be consistent with STL and boost, so I might use that. However, most of you agree that this naming should be avoided whether it compiles or not. So does Stroustrup:
it is unwise to choose names that differ only by capitalization.