Coding Is Like Cooking

A blog by Emily Bache

Onwards with the stars

by | Aug 5, 2008 | Experience Report

pairing fizzbuzz

Michael Feathers and I competed in the “Programming with the Stars” competition today, which was fun, if rather nerve racking. Our category was “TDD from scratch” and we chose to perform the FizzBuzz Kata in python. We chose that because we thought it was simple enough we could do the whole thing in the time limit, just four minutes (!).

It seemed to go smoothly, ping-pong programming, and this is the code we ended up with:

def fizzbuzz(max):
return ["FizzBuzz" if i % 15 == 0
    else "Buzz" if i % 5 == 0
    else "Fizz" if i % 3 == 0
    else i
    for i in range(1, max+1)]

assert fizzbuzz(1) == [1]
assert fizzbuzz(2) == [1,2]
assert fizzbuzz(3) == [1,2,"Fizz"]
assert fizzbuzz(5) == [1,2,"Fizz", 4, "Buzz"]
assert fizzbuzz(15)[-1:] == ["FizzBuzz"]

print "\n".join(map(str, fizzbuzz(15)))

As you can see we didn’t bother with a testing framework of any kind, just a few assert statements, and the code that does the work is all one line, (although we put in some line breaks to make it readable). I was pretty pleased we managed to do it without mishap.

The judges turned out to be Bob Martin, Rachel Davies and Mike Hill, and they weren’t actually as nasty to us as I feared. We got good marks from Rachel and Mike, (8/10 from both), and since Bob was mean to nearly everyone, his 5/10 was actually ok. Only one other pair scored more than us, which puts us through to the next round tomorrow. Our category is going to be “Refactoring”, which is basically Michael’s specialist subject, so hopefully we’ll be able to come up with something good.
first round scores

Hi – I´m Emily!

I am an independent consultant with Bache Consulting and chair of the Samman Technical Coaching Society.  As a technical coach I work with software development organizations who want to get better at the technical practices needed to be agile, including Test-Driven Development, Refactoring and Incremental Design. I live in Gothenburg, Sweden, although I am originally from the UK. I’ve written two books: “Technical Agile Coaching with the Samman method” and  “The Coding Dojo Handbook”. I teach for both O’Reilly and  Pluralsight. I’m married to Geoff Bache, creator of TextTest. I am also on Mastodon as emilybache@sw-development-is.social.

If you’d like to know a bit more about me, my work, and the talks and workshops I offer, please visit my main website: EmilyBache.com. There, you’ll find information about my background, upcoming events, and the services I provide as a technical coach and consultant. It’s a good place to start if you’re curious about how I can support your team in improving coding skills and agile practices.

Blog categories