Wednesday, 14 August 2013

London Code Dojo 25

Monday was London Code Dojo 25 and it returned to the City, hosted by Maker's Academy I think we all had a really productive dojo!


The kata for the night was "Roman Numerals", implementing a parser which could convert "modern" Roman numerals into their actual Arabic number. The important rule was that only 1 smaller numeral could precede a larger one. Hence IV is valid as 4 but IIV isn't valid for trying to represent 3. 

Overall it was a really interesting and education evening! I paired with Mani for two pomodoros and Damien for the last one, code up here:


Go slow to go fast

When doing TDD, going slowly can help you avoid edge cases later. When we came to implementing "subtracting" numerals, like what you have in IV, Mani pointed out it was "a jump too far". We hadn't implemented V yet and the code could do with a refactor once it was. Overall I think doing the two steps was faster and safer than doing it all in one step.

Tests are code as well!

This is a mantra to follow and appreciate. Our test cases could really have benefitted from using parameterised tests. <LINK?> Learning to use this and keeping to it is definitely a goal for me now :)


Simple is beautiful
The Romans Numeral Kata is very simple and straightforward, which lends itself all the more to practising TDD like you mean it. Even though implementing a solution is trivial, the trick comes in keeping things simple and elegant!

Think Functional!

These dojos allow practice that we normally couldn't get otherwise, practice with Java 8 and Lambdas for example. Parsing Roman numerals is actually a problem which maps well to functional programming ;) Pseudo code reads like English: "turn all numerals into values, negate the ones that precede a higher value, sum them all together". Not sure how to do the second step in Java… yet! XD

No comments:

Post a Comment