DRAFT document on coding conventions in kde libraries
Thiago Macieira
thiago at kde.org
Sun Mar 5 13:45:27 GMT 2006
Olivier Goffart wrote:
>Hello,
>
>There is AFAIK not yet a document that tell conventions used in the KDE
>library. That's why I wrote one.
>
>I'd like to place it in developper.kde.org
developer.kde.org
>What have i forget ?
>
>Do you like the idea ?
Thank you, that's a good idea.
A few comments and ideas, though:
- for the naming, mention that acronyms are to be lowercased too. Example:
isNssEnabled instead of isNSSEnabled
- 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.
- also, it might be interesting to add somewhere that complex code that
can should be moved to the private class itself. This gives the compiler
one extra register to work with, since you won't be using "d" all the
time. Again, Qt does this all over the place.
- please add that the constness of the d-pointer is to be used if the
class won't be creating & destroying its d-pointer. If it is going to
implement an implicit sharing mechanism, it should consider using
QSharedDataPointer and make the private class derive from QSharedData.
- getters should all be const, unless there's a strong reason against
that.
- public classes should include the _EXPORT macro for the library they are
on. Non-public classes should not and should be declared in the .cpp file
or in a header ending in _p.h.
- all reference count variables should use QAtomic: do not implement your
own refcounting mechanism using "int".
- explicit: yes, unless the whole point is to allow implicit casting
- namespacing: unless dealing with the central KDE libraries (kdecode,
kdeui), classes should be in the library namespace. New libraries should
choose their namespace.
- finally, add that these are guidelines and that developers may deviate
from them if they have strong reason to, but should avoid doing so. And
make it clear that this applies to KDE libraries, not to application
libraries nor application code.
--
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/9b7837a3/attachment.sig>
More information about the kde-core-devel
mailing list