[Development] Coding style proposal

Jiergir Ogoerg f35f22fan at gmail.com
Thu Jan 2 21:04:27 CET 2014


That's indeed an issue with alphabetic sort, but not the whole Qt
source code follows this:
 bool supportsSelection() const;
 bool supportsFindBuffer() const;

 bool ownsSelection() const;
bool ownsClipboard() const;

Two methods about selection yet between them is one about "find
buffer" (file qclipboard.h).

Anyway, alphabetic order isn't feasible for Qt, in my code/projects I
have the luxury to change API
names cause only I use them (source code not shared with anyone).
Because of that I put the name
first + the action name, which might look weird but is easy to get used to:

buffer() // getter
buffer_set(..) // setter
BufferSupportsFind() // bool

selection() // getter
SelectionMove(..) // move selection
selection_set(..) // setter
SelectionUnset(...) // unset something

It's a mix of Google's approach (getter/setters are lowercase etc) +
my customizations, but obviously
none of this is an option for Qt for different reasons, so case
closed. I get that.


On Thu, Jan 2, 2014 at 9:34 PM, Richard Moore <rich at kde.org> wrote:
> On 2 January 2014 18:33, Jiergir Ogoerg <f35f22fan at gmail.com> wrote:
>> 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.
>
> Having setFoo() miles away from foo() would make it much harder for me
> as a developer.
>
> Rich.
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list