Doing code katas is something I have done for about a year now. Deliberately practicing my skills as a programmer is something that I find very pleasing, and I constantly see an improvement in the way I solve problems.
Initially I did these katas in the privacy of my own home, and never published anything about it. A couple of months however I published a couple of my Project Euler solutions in Javascript. And I got some great feedback from others, which helped me become a better programmer of js. Thus I decided to try to post katas every couple of weeks - but alas, the holiday disrupted my usual habit of doing these exercises. (Apparently summer holidays do that - the amount of physical exercise I get, has also plummeted).
Well, back to the Kata at hand.
The idea to this Kata came from the Coding Dojos page about Roman Numerals Kata. I have created a simple solution for converting numbers to roman numerals, and back again.
I started by writing the tests. So I created a PhpUnit Testcase with the following methods:
A method to check that the roman numerals I get from my new (unimplemented) class would in fact match values I knew were correct. (Some simple values and the year I was born).
A method to check that the values of roman numerals I knew would also match what I knew they should.
From there on it was just happy hacking. The first implementation was quite crude, but passed the tests. (Take a look at the history at github).
From then it was a mather of adding a few tests for Exception handling, and refactoring to a more elegant solution. No doubt it could have been done even better - but this works, and was done in a mather of an hour or so.
Take a look at the source at git hub. And please leave a comment about how you would go about solving the problem.
