TDD for C++ Programmers

C++Recently I’ve been getting a good number of calls from C++ shops interested in doing TDD, despite my heavy Java background. I took on some of the business and had to turn away some to avoid being swamped. Many other folks I know (name dropping time!)–Tim Ottinger, James Grenning, JB Rainsberger, others–have also reported doing C++ work recently.

Is TDD finally taking hold in C++ shops? Does TDD even make sense for C++? I think so, and two current customers believe they’ve been seeing great benefits come from applying it. Building and delivering a C++ TDD course recently helped me come back up to speed in the language to the point where I was comfortably familiar with all of the things I hated about it. 🙂 It makes no sense to take such a difficult language and stab at it without the protection of tests.

I’ve been simultaneously writing more (after a typical winter writing freeze) and looking at Erlang–a much cooler language, challenging in a different kind of way. Meanwhile, my editor at PragProg has been asking for new book ideas. Here were some of my thoughts:

  • Refactoring 2012
  • Modern OO Design (not template metaprogramming!) / Simple Design
  • Object-Oriented Design “In a Flash” (card deck, like Agile in a Flash)

No matter how hard I try to run screaming from C++, there it is right behind me. It’s indeed a powerful language, and there is gobs and gobs of code written in it, and it’s about time we started trying to figure out how to make the best of it. It’s not going away in my lifetime. I also think C++ programmers are not well-served in terms of writings on TDD out there.

So… I decided it was going to be TDD in C++. Tim Ottinger and I put together and just sent out a proposal for a book tentatively named TDD for C++ Programmers (with a catchy subtitle, no doubt). We hope there’s enough demand and interest to get the proposal accepted. If all goes well, we’ll be soliciting reviewers in a few weeks.

I look forward to writing again with Tim! More in an upcoming blog post about our collaborative writing experience.

  1. EL Reply

    Coming from Ruby, I’d definitively buy this book to be more confident when coding in c++!

  2. jlangr Reply

    That’s an interesting direction. My sympathies. 🙂

  3. jlangr Reply

    Update: Now seeking a new co-author. Tim won’t be able to co-author due to other pressing concerns and corporations. Please drop me a line if you have any interest in co-authoring.

  4. Pingback: TDD Is Not Mindless |

  5. Robert Gleeson Reply

    Another person coming from Ruby. I’m looking to branch into other languages, C++ is on the list and I think this could be a awesome companion book to another book that teaches C++.

  6. AIK Reply

    Hi Jeff,
    I saw your “TDD for C++ Programmers” as an upcoming beta in the Pragmatic Bookshelf site. Any chance of me being able to get an advance copy(for the price of course?). I have been reaping many benefits from Grenning’s TDD for Embedded C book, so can’t wait to see what you have to say on TDD for C++. If you wish, I could review it too :).

    Thanks in advance

  7. jlangr Reply

    Hi AIK–

    Send me an email, I’ll add you to the review group.

    The book will be in beta in a few weeks, presumably.


  8. sunday Reply

    Sharing here as this may save someone some grief.
    To fix linker error related to pthread, in CMakeLists.txt move ‘target_link_libraries(test pthread)’ line to the end of the file.

Leave a Reply


captcha *