Tennis Refactoring Kata

Tennis is a very popular sport. The game itself isn’t too hard to understand, but the scoring is a little bit cryptic, using words like “love”, “fifteen”, “thirty”, “fourty”, “deuce”, and “advantage” to describe the score of a game. Essentially, you have to win by 2 and have at least 4 points, but those aren’t the words used.

You start with no points, called “love” and get “fifteen”, “thirty”, and “forty” as your next 3 points. Once both players reach “forty”, we call all subsequent ties “duece” and if a player gets a 1 point lead, they’re said to have “advantage”.

For this exercise, we’re going to using Emily Bache’s Tennis Refactoring Kata. Using that link to her repository, you’ll find sample code for quite a few languages, so pick one that you feel comfortable working with (or want to improve!)

Unlike most of the exercises we do, this one isn’t about building the tests yourself, but is instead showing the value of having those tests in place while refactoring. If you’re ever working on code without tests, you can add a suite like this first.

Kata Instructions

Imagine that you’ve just been assigned to work on this mostly completed code, and your job is to finish it up, fix any bugs you find, and make some notes for improvements you would make.

Source Code

Here’s the link to the source code for this exercise.