- Grow an algorithm bit by bit
- Delay treating exceptions (in this case, because they are more complex)
- Intentionally cause duplication
- Focus on simple structures first
I think the reason is that the first time I started refactoring too soon and that hid the duplication pattern that would have lead me to this simpler solution.
As in the previous version, I extended the kata to also convert decimal numbers over 3999.
This is the resulting code:
and these are the tests using Midje:
To document the TDD process I commited the code after every passing test and every refactor. You can find the commits step by step here.
This time it was a bit easier to derive the algorithm only using strict TDD.
You can find all the code in this repository in GitHub.