Let's say that I've got a class which handles animations. Inside of this class is a boolean called isLooped
and a function which returns this boolean. My question is, what can I do to avoid calling the function and variable the same thing?
I have thought about adding a prefix to my class variables, but that would mean making changes across my entire code base, which I don't desire.
This is entirely a matter of naming conventions, here are two trivial options:
Option #1 You could for example use UpperCamelCase for method names, and LowerCamelCase for member names.
Option #2 You could use LowerCamelCase for method names and member names, and use some kind of a prefix/suffix for member names, such as
m_
, or just_
I prefer option number #2, since it makes life easier when trying to understand which objects are members.