Rubyize this: Live in Vancouver. Refactoring #1.
published Jan 27, 2008
At rubycamp today, I ran a little Rubyize This workshop. Rubyize This is a game invented by François Lamontagne. The idea is that someone puts up a chunk of code that is written in Ruby, but in a not very Rubyish way. Then, everyone in the audience gets to Rubyize it!
We tried to use the most excellent RefactorMyCode.com, but the WiFi was too saturated so we had to resort to posting the code on my blog and people plugging their laptops in to the projector to present their results.
So, this post and the following two will show the original code. Keep in mind that this is intentionally ugly!
We had some great refactorings. If you were at the workshop, please post your refactorings in the comments. I’ll make the pretty and put them in the posting.
Without further ado, here’s the first refactoring. The code is supposed to create a file filled with random numbers, one number per line.
Here’s the first refactoring:
Here’s one from Sam Livingston-Gray
Here’s what I came up with: