Top 5 reasons you should love your ternary operator


I feel the need to take up the cudgels on behalf of my old friend, the ternary operator ?:.

As evidenced by this stackoverflow.com discussion, many people seem to believe that choosing the ternary operator over if/else is purely a matter of personal style, and of readability. Well, it’s not.

Read more of this post

Advertisement

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.