I have some programming exercises available on GitHub. Here is a quick overview of what they are and how to use them.
Movie Rentals Kata
This is based on an exercise created by Mike Cohn, which was taught to me by Robert C. Martin in a mob programming session. The version we used was in Java, but I have translated it to C#. I have taken care to include as many of the problems as possible.
There are two branches:
- master – ready to refactor
- withbugs – has an error to fix before refactoring
The idea behind this exercise is to fix the code. It has many problems that will will flex your object-oriented programming skills. You can try this many times and find you end up with new solutions, each of which will have its merits.
99 Bottles Kata
I created this as an accompaniment to 99 Bottles of OOP by Sandi Metz and Katrina Owen. It is a C# implementation of Shameless Green that is ready for you to try out the techniques discussed in the book.
Everything you need is in the master branch. The approval tests branch was one I created as part of an article I wrote on Migrating to Approval Tests.
Tarnished Rose Kata
Based on the Gilded Rose Kata, Tarnished Rose is a starting point for exercises that will apply directly to anyone having to tame legacy code.
There are two branches:
- master – a legacy application with no tests
- characterised – a legacy application with tests
If you start with master, you get to perform all the tasks of fixing legacy code, including introducing characterising tests. These tests will boost your knowledge of the code, prove the current behaviour, and give you confidence to refactor.
The characterised branch already has these tests, so if you want to get straight into the refactoring part of the exercise, you can start with that.
This one is from scratch. Most people know Tic-tac-toe (or noughts-and-crosses). The task is to create it…
- The game is for two players
- The board is a 3×3 grid
- Each player takes it in turn to place a marker in an empty square
- If a player gets three in a row vertically, horizontally, or diagonally; they win the game
Once achived, can the following variations can be attempted…
Write a computerised “Player 2” for tic-tac-toe.
Connect Four Extension
- Increase the board to a 7 wide, 6 high grid
- Make it so the grid is vertically suspended (i.e. you can’t suspend a play in mid-air it drops to the bottom)
- Make it so you need four in a row
- … all while still supporting the original game