DRAFT document on coding conventions in kde libraries

Harri Porten porten at froglogic.com
Sun Mar 5 15:08:45 GMT 2006


On Sun, 5 Mar 2006, Thiago Macieira wrote:

> - for d-pointers, I'm not sure I like the idea of using a nested class
> called Private. Qt uses an external class all over.

I see no problems with that. The compilers that had problems with internal
classes are no longer supported anyway afaik.

> - getters should all be const, unless there's a strong reason against
> that.

This is a rather difficult subject that I wouldn't let be subsumed by such
a simple statement. Adding const wherever possible makes the author and
user fall into what I call the "const illusion" trap. It seems to promise
something which often simply is not there.

Taking QWidget as an example I'd say that at least functions like layout()
and nextInFocusChain() should either not be const or at least return a
const pointer. Otherwise it just takes one level of indirection to nullify
and const-ness of the object.

Harri.

P.S. I've once tried to write my thoughts up at
http://www.froglogic.com/~porten/const.html but unfortunately never got up
finishing it.






More information about the kde-core-devel mailing list