Awesome Code Katas
I've been doing quite a few Code Katas, especially at Dallas Hack Club. Here is a list of code katas that you may want to try out. I recommend tackling them in the order they are listed :-).
- TOC
- Prime Factors - Rite of Passage
- Bowling Kata - Reinforcement
- Mars Rover - The Transition
- Poker Kata - Picking the Right Test
- Vending Machine Kata - Exploring Behaviors
- Map Kata - En Passe
- Conway's Game of Life
- Mancala
Vending Machine Kata - Exploring Behaviors
By now you should have a good feel for doing katas. You've gone through a few toy katas and have tackled some more complex ones. This kata is pretty much an open book where you can write your own story. There aren't any hard and fast rules in this kata about how a vending machine operates. Use this kata to spec out how you want your vending machine to work. Here is an example of some rules that I've regularly applied to my vending machine kata (again, you don't have to use these rules...feel free to come up with your own).
- Vending machine can be stocked with an assortment of items.
- An item is dispensed if a valid slot is picked and enough money has been inserted into the machine.
- The vending machine tells you if you've selected an item that is currently out of stock.
- The vending machine accepts dollars, quarters, dimes and nickels and will dispense change if change is due.
Context Specification
There is an approach to test driven development called context specification. The idea with context specification is to describe a small part of the system and then implement it. After you have a simple test passing, elaborate on that behavior by introducing a nested context. There are three awesome testing frameworks that allow you to nest context: [NSpec] (for .Net), [rspec] (for ruby), [Jasmine] (for js and coffeescript). Use the Vending Machine kata to explore context specification. Find out how many nested contexts you want to create before things get hard to maintain.
Written: 3/24/2012