Refactoring Dojo: The Gilded Rose Kata

Last week Rafael de Castro (@rafadc) and I facilitated a Coding Dojo for the Madrid Software Craftsmanship meetup group (219 members and growing every week!) in which we participate. The idea was to make a Dojo in which we could practice refactoring.

Iván Stepaniuk standing in the back, and some Madrid Craftsmen and Craftswomen

Myself in the back, standing. Some Madrid Craftsmen and Craftswomen at work!

It went pretty well! This is the second time we meet in the MediaLab Prado in Madrid, a “citizen laboratory for the production, research and dissemination of cultural projects that explore collaborative forms of experimentation and learning that have emerged from digital networks.”, founded by the Madrid City Council, COOL!

For the Dojo we have chosen a well known Kata called “Gilded Rose”, it is a very simple piece of software that updates the quality value of the items in a store following some simple business rules. The problem is that the code sucks, we are asked to add a new feature but the code is so horrible that you don’t even know where to start.

Rafael de Castro Facilitating a Refactoring Dojo

Rafael de Castro (in the back, standing) Facilitating.

We had limited time, so we choose JavaScript, that way nobody would have to install anything special on their computers, and everybody has a text editor and a browser to launch Jasmine, right?. We distributed several pen drives with the same copy of the code plus a working test runner. And because we wanted to focus on the refactoring techniques I also included the tests, already passing.

The schedule

(at least the planned one!)

  • 20m: Introduction to the exercise, explaining the problem.
  • 05m: Distributing the USB pen drives and asking the attendees to sit in pairs, trying that people that has more experience sits with people that does not.
  • 40m: Pomodoro 1
  • 15m: Break: Group discussion on the problems they have found, connecting some of the computers to the projector so the teams explain what are they doing.
  • 40m: Pomodoro 2, changing pairs!
  • 20m: “Show me the code!” We collected every solution on pen drives each pair shows it on the screen and explain their refactors to the group.
  • 05m: Conclusions, Short retrospective, closing.

Protip: ask the people to bring their [WeirdAppleConnector] to VGA adapters if they have them! Also, for the final “show&tell”, it’s easier to collect the code in pen drives again than to connect many laptops to a projector.

The code

The Kata code is on my github account, where you can also find a folder named ‘solutions’ that contains 8 of the solutions that were written during the Dojo. In most of the cases, 3 people participated in writing the code because pairs where swapped in the break.

Happy hacking!

 Content under Attribution-Share Alike 3.0 Unported

About Iván Stepaniuk

I have been writing software for more than fifteen years, in a wide variety of languages and platforms ranging from Assembler to JavaScript and from 8bit micro-controllers to large web applications. See my about page and Google+
This entry was posted in Agile, Community, JavaScript and tagged , , , . Bookmark the permalink.

One Response to Refactoring Dojo: The Gilded Rose Kata

  1. Keyvan (@keyvanakbary, center front of the lower picture!) Made a nice version of the Kata in Coffee with Mocha and grunt!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">