October 26, 2009 10

Roman Numerals

By Enrique Comba Riepenhausen in Katas

For my first kata I have chosen the Ruby Quiz #22: Roman Numerals. The original quiz is split into two parts; converting a number to it’s roman numeral and converting a roman numeral to it’s arabic representation.

In my kata I only perform the former as I wanted to keep the kata as short as possible.

I felt a bit awkward whilst recording the kata, which you will notice due to my typos and lack of flow in some parts of the kata. I have a general stage fright for cameras and recordings, please bare with me while I get used to it. I could also not get KeyCastr working on Snow Leopard so I used the virtual keyboard to make my keystrokes visible.

Many thanks to Techsmith for sponsoring this series with licenses for Camtasia. I didn’t watch the tutorials (apart from the introduction video) and apart from Camtasia crashing in one of the recordings it all went well and easy.

You can check my gitrepo to try it out yourself!

Roman Numerals from Enrique Comba Riepenhausen on Vimeo

I would love to hear the critiques about this kata, but I’d like to ask you for a) kindness and b) comment with your real name so that we can engage in a conversation.

10 Responses to “Roman Numerals”

  1. [...] This post was mentioned on Twitter by Johnno Nolan, ecomba. ecomba said: Roman Numerals kata on katacast http://bit.ly/3TFYXX ! [...]

  2. Andrew Vit says:

    I’m curious, did you originally solve the Ruby Quiz so directly? Or was there a longer route that eventually led to this design?

    It’s unclear to me how you arrived at the solution between 3:30 and 4:50. There seems to be a leap of intuition here, seeing how you write out your NUMERALS lookup table and use divmod straight out, it’s as if you already have the final solution from memory. The rest of the screencast just shows you filling in the table for bigger values, but the essential problem is solved by that point.

    What I find interesting about code katas is observing how the design process unfolds. Without that, you might as well start typing “class” and finish with “end” and just write the whole thing out. But then it’s an exercise in memorizing the code, without any insight into the process…

    Nice job though, you got it done quick!

    • Hi Andrew,

      First of all thanks a lot for sharing your thoughts about my kata!

      To be fair the route to get there, the understanding of the problem took a bit longer than that and required some reading (http://en.wikipedia.org/wiki/Roman_numerals) and tinkering (aka spiking). It is true that I make a big jump when I introduce the algorithm that helps me to solve the problem. I was aware of that and didn’t see how I could do this showing how I came to that conclusion in the frame of a kata.

      You make a very good point about letting a kata show how the design process unfolds, or as I use to say “the code screams at you to be changed to a certain way”, as you work along. I guess this can be done with a much longer kata, explaining my thoughts instead of coding to music. I will try to make up a kata in which I explain my thoughts while I code so that you can see why I make certain leaps and what the thoughts behind them are.

      Thank you for your comments, I (we) will try to keep this site alive with more katas, and hopefully find forms you all enjoy!

  3. James Martin says:

    Thanks for the video, Enrique. I really appreciate the effort you guys are going to.

    Hope these comments are helpful…

    +1:
    * Length (ooer) – if you’re going to do a katacast to music, then 5-10 mins seems to be about right.
    * Tempo – even with a few typos you kept the pace consistent.
    * Well Practiced – you’ve obviously done this one a few times, which showed. It wasn’t faltering.
    * Tools – I’m a sucker for Vim and autospec right now but this is a personal thing. :)

    -1:
    * Navigation – same as Corey’s LCD kata: Lots of jjjj and kkkk navigation can be painful for Vim users to watch
    * Commentary – this is a personal thing and more applicable for longer/more difficult katas, but I like to hear the thought process of the performer vocalised where relevant

    Looking forward to the github specs and more videos soon. Keep up the good work!

    • Thanks a lot James!

      It was all Corey’s idea and he challenged me to this, which I gladly accepted :)

      Answering to your comments:

      Length: I wanted to keep it as short as possible. In the original kata I prepared I wrote all the tests while performing it, but I noticed that this would be a bit boring and repetitive (and looong)

      Tempo: I tend to make a lot of typos when I feel observed (not when I am pairing; which is most of the time; but when I feel the eyes in the neck ;)

      Well Practiced: I indeed practiced the kata a few times (more than 10 times) which helps a lot and I think is essential if you want to perform in front of people or in a screencast.

      Tools: I am living through a “vim come back” this days and I am loving it. Back in 2000 (till 2005 aprox.) I used vim exclusively and for unknown reasons to me I stopped using it. Now I felt the urge to go back to my old friend vim and I am loving it. Would you like to see a kata using any other tool?

      Navigation: I agree that the jjjj and kkk can be a bit anoying and confusing at the same time. But I am not sure if 4j and 3k would help either. I will have to experiment with this and we will see what happens :)

      Commentary: I agree that for longer katas, or katas where you want to explain why you did what it should be better to have a commentary instead of music. I will try and perform one where you can hear my thoughts in the future.

      Thanks a lot for the comments, I will try to incorporate as much from your (and everyone else’s) thoughts into future katas so that you can enjoy them even more.

  4. James Martin says:

    Enrique, some of the screen/word boundary navigation shortcuts might save you some typing: http://www.thegeekstuff.com/2009/03/8-essential-vim-editor-navigation-fundamentals

    On the “tools” front; maybe it would be cool to try the katas in all of the different languages/editors that you know/use regularly (would at least help keep you practiced).

    Andrew, I guess a lot of the Kata is going to be from memory (that’s kind of the point), so should appear rehearsed. I’m going to try this one out tonight and see if there are smaller steps that could be taken in the tests to demonstrate the solution at a more granular level. I had the same reaction when the divmod thing magically happened: “Wow, cool. I wonder if it happened like that the first time.” :)

  5. Ciaran Kelly says:

    Hey Enrique,

    Very nice kata. I hope to see more of these from you soon. Maybe its just my eyes or screen, but I didnt notice any typos.

    Keep up the good work,
    ck

  6. good work enrique!
    i’ve only just come to watch this one. i’d like to see you perform the translation the other way: from roman to arabic! :)

    • Hey Aimee,

      thanks for the comments. I actually didn’t do the reverse (from roman to Arabic) to make the screencast shorter.
      I am sure I can perform the kata one day at the Eden workshop if you want me to and include it in the performance :)

Leave a Reply