Today we are honoured with a Kata from Chris Parsons, Craftsman and founder at Eden Development.
He was delighted by the idea of katas and when he saw the site (and after some conversations we had) he decided to perform a kata for himself to see the real benefit of it.Here is the result of his performance, I hope you like it as much as I did when I saw him performing it live and now in it’s screencast form. — Enrique Comba Riepenhausen
For this kata I flipped through codekata.pragprog.com to try and find something that interested me and that wasn’t too similar to some of the others that I knew were being worked on. After a little while, Back to the Checkout stood out.
You can read the full details in the link above, but the basic idea is to implement the code for a simple checkout that handles scanning of individual items and for special handling of items that are on special offer (i.e. normal price is 50 cents, buy you can buy 3 for $1.30). The checkout code had to be able to accept items in any order and apply a combination of discounts where appropriate.
Katacast: Back to the Checkout from Chris Parsons on Vimeo.
I practiced the kata 15 times before attempting to record it. It originally took me half an hour to write, and slowly I got that down to the time on this recording. The first 5 times were in Textmate, and then I switched to MacVim. I demoed the kata to the guys at the office a couple of days before recording, and I’m grateful for the helpful feedback they gave me.
Thanks again to Camtasia for an excellent and dead-easy recording experience. You can see all the code on github: see the various branches pushed for my different attempts (some better than others!)
I’d be very grateful for comments and feedback on my solution. Please post your name so we can engage in some conversation!