Coding style
#3

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:
  • 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.
Reply


Messages In This Thread
Coding style - by Su37Erich - 09.10.2015, 21:04
Re: Coding style - by MP2 - 10.10.2015, 11:19
Re: Coding style - by Vince - 10.10.2015, 12:10
Re: Coding style - by Su37Erich - 24.10.2015, 00:52
Re: Coding style - by Kaperstone - 24.10.2015, 03:43
Re: Coding style - by Crayder - 24.10.2015, 08:45

Forum Jump:


Users browsing this thread: 1 Guest(s)