Introducing the Noisy Animals kata

Fritz Meissner

The Noisy Animals code kata is a programming exercise designed to teach principles of improving bad code. The exercise consists of:

  • around one page of bad code that generates animal noises (dogs go “woof”, cats go “meow”, etc)
  • tests that verify the behaviour of the code for every supported animal
  • some reflection questions for before and after attempting to improve the code
  • some new requirements to be implemented that affect how the reader might want to organise the code
  • hints for making progress when stuck
  • discussion of ideas in the refactoring community

It is written in Ruby. The code and instructions are all in the github repository.

Inspiration

The exercise owes a substantial debt of inspiration to the exercise and ideas in Sandi Metz and Katrina Owen’s 99 Bottles of OOP, as well as to the Gilded Rose kata.

Relevance to professional programming

When code is continuously updated with only the smallest change possible and never reorganised, it often degrades to a level equivalent to (or worse than) this exercise’s starting point.

Although the example is small and the domain of animal noises trivial, the form of the code and particularly the techniques for improving it are very relevant to professional code.

Why another exercise?

99 Bottles is an amazing book and this exercise is intended to expose some of its ideas (and those of the refactoring community in general) in a shorter form that nudges one towards refactoring without assuming the reader has ever heard of the concept.

99 Bottles is itself very approachable for beginners, but it tends to only be read and discussed by people who are already in (or are connected to others) in the refactoring community.

The Gilded Rose Kata is a wonderful exercise, but its World of Warcraft domain is less and less approachable with the passage of time, even in the tech community.

Contributions welcome

The exercise can no doubt be improved. If you think something about the exercise is less than ideal or you have a new idea for it, you’re welcome to open an issue or a pull request on the repository.