From: James Edward Gray II Date: 2005-03-19T00:05:00+09:00 Subject: Re: Wanted: A nice clean ruby app to disect On Mar 18, 2005, at 8:09 AM, Curt Hibbs wrote: > We've started a new Ruby Users Group in Saint Louis, Missouri (US). We > had our first get together last night over dinner (many thanks to Dave > Thomas who also came since he was in town). About 90% of our members > are new to Ruby, and we decided that a good way to get started would > be to dissect the code of a Ruby app to learn Ruby and its idioms > first-hand from *real* code. > > There's *lots* of Ruby open source projects and lots of code available > for study. But we have to pick something. I'm looking for some Ruby > code that is not too complex, but also not trivially simple. Something > that is fairly clean and makes good use of Ruby idioms. And, > preferable, something that makes good use of unit tests. > > What would you recommend? I sure learn a lot reading the Ruby Quiz submissions every week. Are they too complex, too simple, clean? Do they have unit tests and make use of Ruby idioms? Sometimes. In my opinion, that's what makes them such a valuable tool. You see so many different styles and you can decide what works and what doesn't. I've adopted some habits/tricks in my own code that I've seen in solutions. Are the submissions perfect? No way, but I consider that another feature. Sometimes I spend a lot of time playing with a certain solution to figure out how it works. It's a rewarding search that teaches me a lot. I'll give an example, just because it's fresh in my mind: http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/122593 Take a look at that submission from the Crosswords quiz. Glance down at the "main" code in: if $0 == __FILE__ # ... end See if you can find the subtle "bug" in that code. It works, but not the way the author intended. (Sadly, I found that one after I wrote that summary.) Don't stop there. The rest of that solution is quite interesting. I had to insert a few print statements to fully understand it, when I went over it. Even better, there's a handful of other great solutions for that round. Compare and contrast. That way you get to see everyone's take on just how to use Ruby to accomplish the same task. Enough of the commercial. I'm clearly biased. I just get a lot out of the quizzes and hope everyone else finds them to be a valuable resource as well. James Edward Gray II