DRAFT document on coding conventions in kde libraries

Thiago Macieira thiago at kde.org
Sun Mar 5 15:49:00 GMT 2006


Harri Porten wrote:
>> - 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.

I didn't mean for all methods to be const. I meant that getters should be, 
especially if they are property getters (Q_PROPERTY).

The interesting thing is that, if the value it was getting were in the 
class itself (not in the d-pointer), the compiler wouldn't let you return 
it as a non-const. But the function's constness does not apply to the 
Private class's content -- just the pointer.

One other reason for the other recommendation: complex code should be in 
the Private class.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

5. Swa he géanhwearf tó timbran, and hwonne he cóm, lá! Unix cwæð "Hello, 
World". Ǽfre ǽghwilc wæs glæd and seo woruld wæs fréo.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060305/b05fd81a/attachment.sig>


More information about the kde-core-devel mailing list