I’m pleased to announce that two of my proposed sessions for C++ Now! 2014 have been accepted! I proposed three sessions to the conference: create a refactoring C++ tool in C++ with clang, test-driven development with Boost.Test and Turtle Mock, and automated acceptance testing with FitNesse. I would have been pleased if just one session were accepted and I’m quite happy that two sessions were accepted, even if it does mean a bunch of work for me. Both sessions will be workshop-oriented, meaning we’ll be looking at code and very few, if any, slides. Death to powerpoint! Long live the code!
Making a C++ Refactoring Tool in C++
Making a refactoring C++ tool in C++ using clang is a workshop designed to show you how easy it is to get started making a refactoring. I was inspired by these two presentations from Chandler Carruth:
I’m doing a dry-run of this presentation for the Utah Software Craftsmen group in March. We’ll be working through the remove-void-args exercise I’ve prepared on github. Feedback from this exercise will be used to improve the session for C++ Now! 2014.
The goals of the exercise are:
- Expose you to a working example of using the
libtoolinglibrary in clang.
- Expose you to matching various parts of the C++ language using the abstract syntax tree (AST) matchers in clang.
- Expose you to source-to-source transformations by providing replacement text for a portion of the matched AST.
Refactoring tools are usually integrated into a developer’s environment as more than just a command-line tool. However, I wanted to keep the exercise focused on the refactoring part — this is the interesting bit. Integrating into an IDE or editor is more mundane work that can be left out of the exercise. Therefore, the following are attributes that would be necessary for an end-user ready refactoring tool are outside the scope of the exercise:
- Integration into the user’s editing environment (vim, IDE, etc.).
- Interactively specifying which portions of the code are to be refactored.
- Interactively supplying arguments to the refactoring tool (new identifiers, etc.).
- Reformatting of the refactored code to meet the style of the enclosing code.
MY friend Zhon Johansen has remarked that this refactoring isn’t particularly interesting from an end-user point of view because I could simply search for “(void)” and replace it with “()” in my text editor. While this is true, the focus of this exercise is to expose you to the
libtooling framework and how to apply it on source code. I may end up using a different refactoring for the conference to make the example more relevant to typical problems faced in a code base that aren’t handled by a simple search/replace in an editor.
If you have suggestions of a refactoring that meets both the goals and non-goals above, please open an issue on the github repository for remove-void-args with you suggestions!
Test-Driven Development with Boost.Test and Turtle
During the past year I’ve been working on a rewrite of the documentation for Boost.Test. In order to explain something to someone else, you really need to know it yourself. I’ve been working hard on understanding the library enough to answer people’s questions and along the way I learned a few things myself that weren’t documented very well or at all in the existing documentation. I’ve also been working with Mathieu Champion to improve his already excellent Turtle mock object library.
This workshop is intended for a C++ developer to “get it” when it comes to test-driven development as a design activity as opposed to a testing activity. I was inspired in part for this workshop by the new book Modern C++ Programming with Test-Driven Development: Code Better, Sleep Better. It will combine some insights from that book (i.e. TDD is more about design than it is about testing) as well as my own experiences practicing TDD over the past 5 years. To get a feel for what this session will contain, you can work through the tutorials I wrote in 2009 on practicing test-driven development using Boost.Test: Part 1, Part 2, Part 3, Part 4 and Part 5. You can also work through the Tutorials in my Boost.Test documentation rewrite.