The Season of Ruby continues…
I am staying with the Ruby Koans for now, I really enjoy the layout as I learn the basics of the language and it’s syntax. To this point I have covered asserts, the notion of nil (it really is an object), objects, arrays, hashes, strings, symbols, and my favorite…regular expressions.
I have a love-hate relationship with regular expressions. Unlike many programmers who may deal with a lot of text, in my world of medical devices and laboratory automation I don’t need to rely on regex all that much. To paraphrase the most interesting man in the world, “I don’t always use Regexp, but when I do, it is a powerful, painful, awful, and wonderful experience….every time”.
Things that I have found interesting or noteworthy about the most recent koans:
I was a little confused about Ruby symbols at first. How do they get “initialized”, how do you use them, why don’t they take an “=”, what can you do with them once you’ve got them. After some Googling, things were starting to take shape, but I was still not perfectly clear on them. But wait….
I really love the ability to play around with ideas in a REPL. Verdammelt had an interesting article about using a REPL and TDD and this seemed like a perfect place for some experimentation. I was able to pretty quickly satisfy my curiousity and questions about Ruby symbols in the IRB. I thought it was neat how one answer may lead to another question and so on…very exploratory.
Which brings us to the aforementioned regular expressions. Some people love regular expressions. Some people can whip a regex out of thin air to find the middle names of everyone with a blue house, between the ages of 38-43, with 2 dogs OR 1 ferret and 3 parrots. I am not one of those people. I always liked this joke
Some people, when confronted with a problem, think “I know, I'll use regular expressions.”
Now they have two problems.
But interestingly I had an “a ha” moment while doing the Regexp exercises. It wasn’t some “the skies opened and I know all Regexp syntax by heart now”. That unfortunately did not happen. It was that it reinforced this notion of TDD:
A well-written test suite _IS_ documentation.
A well written test suite _IS_ a specification.
I love that about TDD and it is one of the reasons I am having so much fun with the Ruby Koans. Every test clearly expresses a single, intended behavior.
Stay tuned for a retrospective on the first iteration, and if you have tips on good Ruby resources I would love to hear them.