Katas
Contents of this page:
Tools
Cyber-dojo
- Cyber-dojo is a fantastic tool for getting straight into a kata in any language without setting up an IDE or dev environment. Really useful for workshopping in groups. Note that if you are not using it in a not-for-profit context, you should buy a (very cheap) licence. Details here.
- If you follow this link you’ll see a list of katas on the left and then when you select one it describes the kata
- Quick start guide if you’re working in “classroom” mode - for instance several pairs working independently on the same exercise:
- Go to home page
- Click create a new practice
- Select exercise and language
- Click Classroom
- Note the ID - or note the url after you click OK - or just add your ID to this url: https://cyber-dojo.proagile.se/creator/enter?id=
- Now for each pair:
- They’ll visit that url, or click “enter an existing practice” and enter the ID
- one will have to click “enter group practice as new avatar”
- the other will have to click “enter group practice as existing avatar” - selecting the avatar created by the first
- The facilitator can watch the progress of the pairs using the following link (add your ID to the end):
- https://cyber-dojo.proagile.se/dashboard/show/
- Quick start guide if you’re working solo:
- Go to main home page
- If this is your first time: Select “Create a new practice”
- If you’ve already started work: Click “enter an existing practice” and enter your saved ID
- Select a particular challenge and click next
- Select a language and click next
- Select “solo”
- Make a note of your ID and click OK (if you forget to make a note, you can still see it in your url on the next page)
- If you return at a later date, you can use this ID to continue where you left off
- The first thing you see will be an explanation of the problem
- On the left hand side (depending on language) will be a code file and a test file
- !! The initial code you see will probably have nothing to do with the actual challenge you are attempting. The platform uses the same “hiker” code by default for all challenges. This code is just there as a guide to give you a reminder of the syntax for tests and code in the language / test platform you have chosen.
- You’ll have to rename the files - which isn’t obvious - the way to do this is to select the file and then click the grey square button to the right of the
+
and-
buttons, top left
- Write tests and code to make those tests pass by selecting the files on the left
- Your first job is to write a test and see it fail. Then make it pass. Your next job is to write more failing tests, one at a time, and make them pass to gradually build a solution. Use tiny steps! The smaller the better.
- Keep clicking test after every code change, to run the tests
- Every time you run tests, you get a red, amber or green blob appear at the top. You can click on previous blobs to see the code at previous states.
Kata definitions
- Made Tech Learn Tech katas
- (includes Bowling, Mumbling, Number to LCD, Roman numerals, Snake, Tennis, Tennis Refactoring, Turnstile, Wordwrap, Test Framework, Video Store and Mars Rover)
- Note that the bowling kata can sometimes be a bit opaque (because if you don’t play the game, the scoring is quite complex), but I’ve updated the readme on the Made Tech site to have a simpler explanation (in case that gets lost, I’ve also added it to the readme in my repo)
- Made Tech Learn Tech Sparring Exercises (overview, then Tic Tac Toe (aka Noughts and Crosses) and Payroll exercises)
- Minimax algorithm:
- To get an unbeatable AI for the tic-tac-toe kata, people generally use the Minimax algorithm.
- TDDing minimax can be tricky. I ended up drawing a lot of diagrams. My notes and diagrams are here.
- The tests for my TDDed minimax implementation are here, and the code is here.
- My version of the game is deployed here (the UI is terrible, I was mostly focused on TDDing minimax).
- Minimax algorithm:
- Cyber Dojo (see above): If you follow this link you’ll see a list of katas on the left and then when you select one it describes the kata
- There are six good refactoring katas pinned to the top of Emily Bache’s github account
GitHub Repos
Sadly by necessity some of my repos are private. Those that are private are clearly marked. For those that are, please don’t ask me to share the code, because I can’t. They’re listed here purely for my reference.
- The elevator kata:
- GameOfLife01
- FizzBuzzKata
- SimpleCardGameKata
- BowlingGameKata-TDD-as-if-you-meant-it-
- CoduranceBankKata (PRIVATE)
- TrainRoutes (PRIVATE)
- Thoughtworks recruitment exercise
- ScreeningMathParser (PRIVATE)
- I think this was the recruitment test when I joined NICE as a contractor.
- NumberToLCD_Kata (PRIVATE)
- Made Tech recruitment exercise
- Lots of Ruby katas are linked to on my Ruby page
- There’s also a Quick-start Ruby kata guide
- tic-tac-toe kata in Ruby
- Also, this is a nice implementation of the tic-tac-toe kata from our Made Tech academy engineers Richard and Claire, pairing together - note that it has a good example of using TDD to code the minimax game-playing AI algorithm