On Tuesday 25th February, I had the honour of speaking about “C++ Testing Techniques, Tips and Tricks” at the 3rd edition of CppEurope in Bucharest, Romania.
Things I particularly liked about this conference:
- Lovely variety of strong talks.
- Great food.
- “Ask the speaker” session: all the speakers were available for 45 minutes, for questions and discussions.
- Retrospective at the end of the day.
- Speakers were very well looked after.
- Everyone in the audience sat at a table, so it was easy to take notes.
- Less waste: instead of give-away bags, freebies were left on the tables, one per seat… If you didn’t want one of the gifts, and left it behind, it was presumably re-used, instead of being thrown away.
My talk “C++ Testing Techniques, Tips and Tricks” was a significant update on the talk of the same name that I gave at C++ London in November 2019.
With a 45 minute slot, I focused on giving general pointers to practices that I have found helpful when writing automated tests of C++ code.
J. Daniel Garcìa: C++ programming in a parallel world
I hadn’t yet had much time to explore C++ 11’s concurrency facilities, so this was a welcome and nice, clear introduction to both concurrency and C++ 17’s parallelism features.
It was a helpful reminder that using
std::for_each is a bit of a smell, as there is usually a better (more specific) algorithm available.
Daniel closed with an overview of the Generic Reusable Parallel Pattern Interface library - GrPPI.
Alexandru Bolboaca: Refactoring C++ legacy code through pure functions
I’m particularly interested in efficient, reliable techniques for improving legacy code, so this talk was right up my street, and the one that was most immediately of use to me.
Alex talked through the current, standard methods for dealing with legacy code, which were all either unreliable or slow and requiring great skill and practice.
He went on to describe a technique he has been developing, that involves:
- Refactoring the code to pure functions (where inputs are never modified, and the outputs are repeatably consistent, for a given set of input values, and there is no saved state and no side-effects)
- Writing data-driven or property based tests (or Approval Tests!)
- Refactoring the pure functions to a cohesive set of classes (or whatever suits your taste)
A big selling point is that because it only requires common refactorings that are typically supported by modern IDEs, it’s possible to keep working at it for hours in a day, without getting too tired and making mistakes.
Alex is still experimenting with this technique, but I think it’s very exciting.
Videos with more information:
- Pure Functions as Nominal Format for Design with Legacy Code with Alex Bolboaca and Adrian Bolboaca - Alex Bolboaca and Adrian Bolboaca explain the idea.
- CodeCast: Refactor C++ legacy code through pure functions - Demo Part 1
Peter Hilton: Technical documentation is a backup so make sure it works
Peter told some very interesting stories about working in different environments, with different levels of documentation - from “many feet of shelf space”, to “absolutely none”.
The talk made clear recommendations for how to do all these, effectively:
- Write good code comments (including focusing on writing good code that needs minimal explanatory comments)
- Provide a clear README, to get people started with the project
- Provide special-purpose documentation for specific needs
I think that this talk, in conjunction with Daniele Procida’s excellent talk ‘What nobody tells you about documentation’, gives very good advice on writing clear, effective, usable documentation.
Arno Schödl: The C++ rvalue lifetime disaster
This was an in-depth treatment of problems with rvalues that developers need to be aware of, to avoid memory-corruption in code. A video of an earlier presentation, at C++ Russia is available.
Klaus Iglberger: Embrace No-Paradigm Programming!
The last talk of the day was a great comparison of different approaches to representation shapes in C++. About 8 different approaches were compared and rated on various attributes, like performance and readability.
The conclusions were:
- Understand the virtues of “Modern C++”
- Reduce the use of pointers and inheritance hierarchies
- Prefer value semantics
- Keep your code simple
- Learn about the different programming paradigms
- Learn about their advantages and weaknesses
- Pick the good ideas
- There is no “one-size-fits-all” solution
Links and Future Dates
- The talks:
- The conference:
- Conference organisers:
- Next editions of the conference:
- Konstanz, Germany: 6 October 2020
- Bucharest, Romania: 23 February, 2021
Overall, this was an excellent conference - enjoyable, interesting, and very well run - Highly Recommended!