News just in: twin giraffes born in France. They’re adorable!
Month: March 2007
Coding Dojo 9
I’m just back from Dojo#9. We attempted Kata 4 again, but in Ruby this time. Even though I was the only one with much Ruby experience behind me, it still wasn’t much of a problem in practise. I did some cheat sheets, but they didn’t seem to be used much.
Exactly the same as the last time, we only completed the first part of the kata. I started the session by writing a small amount of code. In a very non-object oriented fashion. However, I honestly believe that for this problem an OO solution was utter overkill. The testing was probably useful, but to be quite frank a program this short can be visually inspected so easily, I hardly feel it’s worth it. Heresy, I know.
This is what I was aiming towards.
day = nil min_spread = nil File.foreach(ARGV) do |line| if line =~ /^s*(d+)s+(d+)s+(d+)/ spread = $2.to_i - $3.to_i if !min_spread || spread < min_spread min_spread = spread day = $1 end end end puts day
I’m pleased about using regexes though. They make the problem simpler (and more robust) than the previous Java solution using
Now, when it came to refactoring the program to get to the third part of the kata, an OO solution would have been more appropriate. Because you need to carry some state around, and you can obviously use inheritance to model the differences. And by that point, you’ve got two working programs you can extract a sensible design from.
Ah well. An entertaining evening. Big thanks to Joh for organising and FP for hosting. Sorry for disturbing the late workers…
Aunty appears to be preoccupied with coffee today.
I’ve mentioned this to a few people offline, but I thought I’d better announce it proper. We’re expecting a baby! It’s at 27 weeks right now, so is due around the end of May.
So I need to try and wind down on some of the other activities I’ve been partaking in and think about things like what pram to buy… So much to do, so little time. But such promise.
The galaxy’s greatest comic has just turned 30. Well done Tharg, old chap!
Keep up the good work—I’m still enjoying it.