10.10.2015, 12:10
There is a difference between Systems Hungarian and Apps Hungarian. Systems Hungarian encodes the variable's type in its name (i.e. i for integer, f for float, the ever notorious sz for string, etc). Frankly this is utterly stupid, since a variable's type can and should be deducted from its name. I don't need "sz" to tell me that "name" is a string. Apps Hungarian on the other hand encodes the purpose of the variable, like g for global, and that is of course a lot more useful.
There are a few more conventions I tend to stick to:
There are a few more conventions I tend to stick to:
- All constants are written in ALL_CAPS, with underscores. That includes constants defined with #define and const, but also names of enumerators and the enumerator specifiers themselves as these are all also constants.
- Variable names always start with a lowercase letter and use lowerCamelCase, no underscores.
- Function names always start with an uppercase letter and use UpperCamelCase, no underscores.
- A function does something and must therefore always include a verb in its name (get, set, show, hide, create, destroy, etc).
- No abbreviations of any kind in variable or function names unless the abbreviation is well known.