playground-libs/libkvkontakte has moved to kdereview
David Faure
faure at kde.org
Fri Aug 26 11:45:37 BST 2011
On Thursday 25 August 2011 19:23:10 Alexander Potashev wrote:
> 2011/8/25 Albert Astals Cid <aacid at kde.org>:
> > The point is that usually you do not know what the library will end up
> > doing and by using d-pointers everywhere you make it easier for
> > yourself to maintain binary compatibility in the future.
>
> But in the case that most classes won't grow in the future by using my
> strategy (keeping d-ptr NULL when possible) we cut down the number of
> memory allocations, and also simplify the existing code that doesn't
> work with the private class' data.
But you can't remove member variables, or change their types (if the size
differs), and you have to be extra careful to not write inline methods that
use the member variables because then you're screwed if you want to change
anything.
It also means you need to #include a lot more stuff into your header file.
Cutting down on the number of memory allocations is important in very low-
level often-allocated classes e.g. (QChar), but for anything else I doubt it
makes much difference.
A last argument, code is easier to maintain if it follows the same rules
everywhere. So in all "public library" code (Qt, kdelibs, and all other public
libs) we should do things the same way, to ease maintainance.
--
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).
More information about the kde-core-devel
mailing list