[Development] Coding style proposal

Jiergir Ogoerg f35f22fan at gmail.com
Thu Jan 2 19:33:29 CET 2014


It's not for documentation purposes (not for those using Qt to create
apps), but for those working with the Qt code.
Currently, if you're coding a method you put it virtually anywhere in the file.
If you have 30 methods they're put alphabetically in the docs - and
it's not about the docs,
when you dig the source code they're put randomly like spaghetti.

If it was ordered, then you'd know to scroll up to the top if you're
looking for a method called "awesome()",
if you got another method "awesomeAndMore()" - you know it's next to
awesome(), it can't
be at the bottom or in the middle of the source code (like now).

There could be some simple rules when this would break the code.

Anyway the only real reason I don't see it materializing is because it
had to be used from the start,
by now it's too late.



On Thu, Jan 2, 2014 at 9:34 AM, Konstantin Ritt <ritt.ks at gmail.com> wrote:
> 1. In cpp, we typically use enums for numeric constants. In Qt coding style,
> enums are in CamelCase.
> 2. Just a wasting of time. Simply use generated documentation rather than
> scroll over the header files (Qt docs are very good, you know).
>
> Regards,
> Konstantin
>
>
> 2014/1/2 Jiergir Ogoerg <f35f22fan at gmail.com>
>>
>> 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.
>> _______________________________________________
>> Development mailing list
>> Development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/development
>
>



More information about the Development mailing list