Refactoring an Horrible Codebase Guided by Tests

Giovanni Lodi, iflix Part of DW18

This workshop will teach how to refactor code using unit tests to ensure that no regression is introduced. It aims to be a very practical way to learn about Test Driven Development.

Often when learning about unit testing we read articles or watch tutorials that use toy examples. These are great to introduce the concepts behind TDD, but fail to bridge the gap with the world code.

In this workshop the attendees will get the chance to work on an actual horrible codebase, a TODO list app entirely written between UIAppDelegate and its view controllers.

We’ll start from there and make it into a more sane codebase, one refactor at a time. By doing this we’ll practice our testing and refactoring muscles.

To keep the audience engaged we’ll setup as pairs and “play ping-pong”. One individual will write a unit test, the other the code to make it pass. For each incremental refactor one pair from the audience will present their solution, giving a chance to the group to compare and discuss it.

Scaffold code will be provided to bridge the gaps when necessary, the focus is in finding ways to write tests for existing code and then to make that code better, not to write yet another UITableViewDataSource.