Moving a Method via Mikado

We could consider a WAV snippet, or possibly a WAV snippet writer, as an abstraction of its own. The name of our primary class, WavReader, already suggests that anything to do with writing snippets is an inappropriate responsibility. Further, we are making extensive changes to the snippet logic and want to isolate the changes to a class with smaller scope.

As a short-term Mikado Goal, we want to extract the writeSnippet function into its own class, Snippet. Once we complete the immediate goal, we plan to clean the Snippet code considerably. One goal at a time, however.

Given the space constraints of a book, this is a smaller example, but it’s no less real than your regular refactoring challenges. It’s also surprising ...

Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.