I used a mix of a bit of TDD, a lot of REPL-driven development (RDD) following this cycle:
- Write a failing test (using examples that a bit more complicated than the typical ones you use when doing only TDD).
- Explore and triangulate on the REPL until I made the test pass with some ugly but complete solution.
- Refactor the code to make it more readable.
These are the tests I wrote using Midje:
and this the resulting code:
See all the commits here if you want to follow the process.
You can find all the code on GitHub.