Heise Developer: Pimp My Pimpl (part 1)

For you German speakers out there, my second Heise Developer article, “Pimp my Pimpl: Vor- und Nachteile des d-Zeiger-Idioms, Teil 1“, just went live on Heise’s site.

[[EDIT 2011-04-16: An English version is now available]

It’s part one of a two-part article focusing on the advantages and disadvantages of the pimpl idiom.

From the article:

Als bekanntes C++-Idiom erlaubt Pimpl es dem Klassenautor, die Schnittstelle von der Implementierung einer Klasse in einem Maße zu trennen, wie das in C++ eigentlich nicht vorgesehen ist. Als positiver Nebeneffekt beschleunigt der Einsatz von d-Zeigern Übersetzungsläufe, erleichtert die Implementierung von Transaktionssemantik und erlaubt durch erweiterte Mittel der Komposition mitunter zur Laufzeit effizientere Implementierungen.

Nicht alles ist jedoch gut beim Einsatz von d-Zeigern: Neben der zusätzlichen Private-Klasse und deren dynamischer Speicheranforderung bereiten die geänderte const-Methoden-Semantik und Allokationssequenzfehler Sorgen.

About these ads

About marcmutz
Marc Mutz is a Senior Software Engineer, Trainer, and Consultant with KDAB.

7 Responses to Heise Developer: Pimp My Pimpl (part 1)

  1. Fazer says:

    Can we count on English translation of your article? :-)

    • marcmutz says:

      Yes, I have obtained permission to publish an English version on this blog. It will happen sometime during December, probably.

  2. Matthias Pospiech says:

    Really interesting to read. I would like to know if this way of accessing variables makes any difference in speed if I use this for CPU consuming calculations, where the variable access is made via pimpl idiom.
    Not long ago someone told me that in his company this would not be used because of the decrease in speed in algorithms.

    • marcmutz says:

      Yeah, it’s a trade-off, as usual. If you have simple data classes, then pimpl produces noticeable overhead (not only through the indirection, but also because you can’t have inline functions anymore). If you can, moving the function onto the Private class is one option to get some speed back.

  3. peterbite says:

    When is the second part of the article due? I can’t wait!

  4. Pingback: Translated: Pimp My Pimpl (part 1) « -Wmarc

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: