D pointers

Andre Eisenbach int2str at gmail.com
Mon Oct 3 06:34:03 BST 2005


2005/10/2, Christoph Cullmann <cullmann at babylon2k.de>:
> I think a common coding guideline for kdelibs which enforces usage of the
> d-pointer for all private members sounds sane, the headers stay clean, the
> stuff is better hidden and BC keeping is made more easy.

Personally, I'm a huge fan of d-pointers. The maintainability benefits
cannot be ignored. I wish I'd have insisted on them earlier in one of
the projects I am working on.

If I really had to find a problem with them, I'd point out that using
a d-pointer pretty much automatically requires a destructor (you could
get rid of that with a smart ptr I suppose), a copy constructor and an
assigment operator (the rule of three....). This may not be a problem
for most classes (like the KURL example, which already has all three),
but some very small classes would be made more complex and less clean
by adding all these functions.

Bottom line, developer discretion is advised :D.

Cheers,
    Andre




More information about the kde-core-devel mailing list