[Development] Coding style proposal

Jiergir Ogoerg f35f22fan at gmail.com
Thu Jan 2 06:42:01 CET 2014


Hi,

1. Constant names
Typically constants are named UPPER_CASE which is slightly annoying
(looks like shouting) and look like macros which are also named upper case.

I'd propose naming constants with a lowercase "k" followed by camel case:
const int kMonthCount = 12;

It makes it easy to distinguish them from macros.
I read this idea on Google's C++ coding style page and use it myself now for my
projects.

Should apply to global constants, those local to functions/methods should be
named at will since their scope is limited.
Current constants shouldn't be rewritten, just the code from now on.

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Constant_Names

Again, not because Google does so, but because I found the idea good.

2. Methods in alphabetic order
This one is less likely to be adopted because a lot of classes' methods
would need to be rearranged and nobody has that much time. Nonetheless.
The methods of the classes (except ctors and dtors) can be arranged
alphabetically so
that when you think of a method you know which way (up or down) you need to
scroll and basically you know in advance where to find it.



More information about the Development mailing list