Coding Dojo Challenge: Refactoring

Emily Bache

Workshop: 90 minutes

Summary

In this hands-on session we will be working on a rather smelly piece of code which helpfully has a fairly comprehensive suite of automated tests. Refactoring is one of the key skills of Test-Driven Development, and this is your chance to really practice it. The idea is not to rewrite the code from scratch, but rather, by taking small refactoring steps, gradually transform the code into a paragon of readability and elegance.

We’ll be stepping into the Coding Dojo together, which is a safe place designed for learning, where it doesn’t matter if we make mistakes. In fact all the code will be thrown away afterwards. You should feel free to experiment, try out different refactoring approaches, and get feedback from your peers. The great thing about this Kata is that since the tests are very good and very quick to run, they will catch every little refactoring mistake you make. You should experience how programming is supposed to be – smooth, calm, and always minutes away from committable code. The last part of the session is the retrospective, when we discuss what we’ve learnt, and how we can apply our new skills in our daily production code.

The code kata we’ll be looking at is “Tennis” (Java, Python, C++ etc). If you want to practice using your familiar development tools, please download the code and set up a project in advance of the session. Otherwise you can just come and use the cyber-dojo practice environment, which I’ll have set up in advance.

Download Slides

Short Bio

Emily Bache has been a software developer and test engineer for nearly 15 years, working in organizations as diverse as small startup and large corporation. These days Emily is an independent consultant specializing in automated testing and agile methods. Emily has recently published a book, “The Coding Dojo Handbook”, based on her work teaching and learning skills like Test Driven Development. Emily has run Coding Dojos at conferences, in companies, with user groups, and has facilitated several Code Retreat events. Emily regularly speaks at international conferences such as XP, Agile Testing Days, ACCU, and currently acts as program chair for Scandinavian Developer Conference.