Refactoring for Testable C++

room: York, M — time: Thursday 14:00-15:30, Thursday 16:00-17:30
Average Rating: -

We will present many hard-to-test c++ idioms and multiple refactorings for making the code testable. Students who need to test and refactor legacy C++ code as they transition to test-driven development, will learn techniques to help them do this work safely and with minimal changes in the performance. We’ll cover several legacy idioms in which code is initially not accessible by tests. We’ll fix these and other testability problems with refactorings like “Extract Method” or “Extract Class”, and C++-specific techniques involving the preprocessor, “friend”, and changing access Levels. Testing techniques will include stub and mock objects and dependency-injection.

Exercises for the student will be use gcc with or without Ecilipse on Linux or Macintosh, or Eclipse with MinGW and gcc on Windows.

Process/Mechanics

Presentation, demonstration, and student lab work in half-hour cycles. (more detail tbd)

Topics covered: parameterizing for testability, accessing private functions (and extract-class/move-method refactoring), overcoming testability issues with singletons and static data, what to do with non-virtual functions that you can’t make virtual (adapting foreign classes)