In the Fishbowl

Posted by Doug Wed, 08 Mar 2006 13:43:13 GMT

At last night’s XP Cinci we did an interesting exercise called “The Fishbowl”. Mark Windholtz setup his powerbook with a terminal, Safari, TextMate and a time tracking application he had been working on. We then each took turns pair programming on the big screen. While there were two of us “at the console” all the time, we swapped one of them out every 10 minutes.

The exercise was interesting for several reasons. Mostly it turned out to be a good example of what test driven development looks like in Ruby on Rails. The skill level of xp-cinci is split pretty evenly. About half of us have done significant RoR development and the other half is either just interested or just learning. Regardless of skill level though, no one was going to code in public at an XP meeting without writing tests. The best way to learn TDD is by doing. Until you’ve lived through the development cycle of TDD it’s hard to really grasp what it feels like.

The other benefit from the exercise was a fairly lively discussion on “this is how we do it in Rails” versus “this is what I’m used to in Java.” Most of xp-cinci comes from a strong Java background. Even though about half of us are “ruby nubies,” pretty much everyone has a very strong developer background with one technology or another. Here’s a for-instance. I coded up a method that used MyModel.find_by_id(params[:id]) and was asked why I used find_by_id rather than just find. I said that I liked how find_by_id returned nil so I could use it as a false value when doing error checking. As a long-time Java smart-guy, Ed Summerfield was pretty quick to jump on this as a bad practice. He demonstrated how his Rails controllers looked using begin and rescue. I’m not entirely convinced that assigning nil to an object as a fail condition is bad, but his code looked fairly neat with all his error trapping in rescue blocks.

While the skill levels of various members varied, our application we worked on wasn’t really the typical “hello world” style application of tutorials. We started with a working application. Mark and Scott are actually using the application as part of their consulting work at Rails Studio. This gave us the chance to work in a more “normal” fare. We had an existing database we were migrating; we had existing code we had to live within; and we had a “real” customer looking for “real” improvements to their application.

Last night’s meeting was different from our usual fare. It was back to a hands on style where we actually wrote code. While we didn’t get very far in terms of feature points, I think we made a lot of progress in general understanding of both coding practices and Rails development. I hope we continue doing more and talking less.

Posted in , , ,  | Tags , , ,  | 5 comments

Presentations? We don't need no stink'n Powerpoint!

Posted by Doug Wed, 01 Mar 2006 22:51:06 GMT

I gave a “bootcamp” style presentation today at work on Test Driven Development on Rails. I was struggling to figure out what tool to use to actually compose and give the presentation. S5 is a tool from Eric Meyer that uses XHTML, Javascript, and CSS to make a web-based presentation. It’s really cool. Rather than all the typing needed to write valid XHTML, I wrote a Ruby script to convert Textile to S5. I’ve included the Ruby code needed and my TDD presentation.

BTW, you can view the live presentation here

Posted in , ,  | Tags ,  | 8 comments

How Old Are You?

Posted by Doug Thu, 05 Jan 2006 18:49:22 GMT

In one of my Ruby on Rails apps, I have a User class with a dob date of birth field. My client wants me to display the user’s age.

I had added this code a very long time ago:

def age
  (Date.today - self.dob).to_i / 365.25
end

I just went back and looked at that and was surprised I had let that code stand. It was just so smelly. I poked around and didn’t find any good helpers to clean it up. So, I started asking around to the Ruby smart-guys I know. Not to name drop, but Jim Weirich is a member of XP Cincinnati. When I asked him about it he responded with this paste

That demonstrates a lot of things I like about Jim. First, he’s a super friendly guy and very accessible. I don’t remember if he gave me his AIM nick or if it’s listed on his web site. Either way, he never acts bothered by my somewhat periodic interruptions about ruby related stuff. Second, he responded with code; not just code, but code with unit tests; not just simple unit tests, but fairly exhaustive unit tests. He was able to demonstrate with those tests why my algorithm wasn’t good enough; several of his tests failed with my code.

Jim practices what he preaches. He’s a big advocate for both Ruby and Test Driven Development. Even with this simple exercise he started off with good tests. Thanks Jim! I appreciate your help.

Posted in ,  | Tags ,  | 6 comments

Older posts: 1 2

Copyright 2001 - 2005 by Lathi.net and Doug Alcorn

Creative Commons, Some Rights Reserved Ruby on Rails Developer Powered by Debian GNU/Linux Powered by Typo