Mark Needham

Thoughts on Software Development

Coding Dojo #4: Roman Numerals

with one comment

We ran our 4th coding dojo on Thursday night, attempting to solve the Roman Numerals problem from the TDD Problems website.

The Format

We ran with the Randori approach again with between 4-6 participants taking part. We coded for about an hour and a half.

The pair coding were sat at the front of the room this time in an attempt to keep the focus on the code, a problem identified last week.

What We Learnt

  • I had worked on this problem myself a couple of weeks ago but it was interesting to note how many more of the edge cases we managed to cover when working as a group. We had an discussion around where the validation of what constitutes a valid roman numeral should go. We ended up validating when the roman numeral object was converted into an integer, the other option being to do constructor validation. I’m not sure exactly when each approach is applicable – I would tend to do constructor validation when data is coming in from the user interface otherwise validating when the object is used.
  • Having the pair at sit at the front of the room worked much better in terms of stopping others drawing on the white board and we seemed to achieve greater focus on the problem than in the previous weeks although I’m not sure whether or not this is directly linked to the positioning of the coding pair.
  • The idea of keeping minimal state in the code was an interesting idea that was suggested early on and one which we kept to. I’ve not considered this as part of my approach to solving problems before but it makes sense in helping to drive simplicity of design.
  • The drive for the green bar was again in evidence – on one occasion I tried to refactor and make the test pass in one go, forgetting that this would keep us away from the green bar for longer. This was pointed out by my pair and I backtracked the refactoring and just made the bar green.

Written by Mark Needham

November 30th, 2008 at 5:58 pm

Posted in Coding Dojo

Tagged with

  • http://robinclowers.blogspot.com Robin Clowers

    Hi Mark, I have really enjoyed your posts on Coding Dojo’s, it’s an activity I have been meaning to try for myself.

    I find it interesting that you chose to validate on use of an instance, rather that on creation. I have found it is usually better to fail fast; if you can tell if the object is valid on construction, you should throw an exception then. Also, consumers of the class don’t need to check for failure every time they use the object, only when the construct it.

    Just my 2 cents…