Red Squirrel Reflections
Dave Hoover explores the psychology of software development

Dave Hoover
dave.hoover@gmail.com

Categories
All [Atom]
Craftsmanship [Atom]
Dynamic [Atom]
Intersection [Atom]
Learning [Atom]
Links [Atom]
Polyglot [Atom]
Projects [Atom]
XP [Atom]
Old Blog

Obtivian Blogs

Andy Maleh
Colin Harris
Fred Polgardy
Jim Breen
Kevin Taylor
Todd Webb
Turner King
Tyler Jennings

Archives

March 2009 (1)
January 2009 (1)
December 2008 (1)
October 2008 (3)
September 2008 (1)
June 2008 (4)
April 2008 (3)
March 2008 (1)
February 2008 (1)
August 2007 (1)
July 2007 (1)
June 2007 (1)
May 2007 (4)
April 2007 (3)
March 2007 (5)
February 2007 (6)
January 2007 (6)
December 2006 (10)
November 2006 (5)
October 2006 (8)
September 2006 (8)
August 2006 (5)
July 2006 (12)
June 2006 (7)
May 2006 (5)
April 2006 (5)
March 2006 (4)
February 2006 (2)
January 2006 (5)
December 2005 (5)
November 2005 (3)
October 2005 (3)
September 2005 (6)
August 2005 (4)
July 2005 (7)
June 2005 (14)
May 2005 (6)
April 2005 (8)
March 2005 (9)
February 2005 (11)
January 2005 (16)
Old Archives

 

Tue, 25 Jul 2006

Agile Retrospectives: Making Good Teams Great

Two of my favorite facilitators, Ester Derby and Diana Larsen, have written the long-awaited follow-up to Norm Kerth's seminal work. The following was my response after I read an early draft of Agile Retrospectives:
Two of the software industry's leading facilitators have taken their many years of retrospective experience and distilled them into an approachable reference for agile team leaders. For all of the self-made facilitators out there who have been winging it, this book will provide a solid foundation to improve the effectiveness of your iteration, release, and project retrospectives.

[/xp] permanent link

Mon, 24 Jul 2006

SafariWatir 0.1.1

SafariWatir now offers feedback when you try to access an element that doesn't exist...
browser = Watir::Safari.start("http://google.com/")
browser.button(:name, "foo").click
Watir::Exception::UnknownObjectException: Unable to locate Button element with name of foo.
        from /usr/local/lib/ruby/gems/1.8/gems/safariwatir-0.1.1/./safariwatir/scripter.rb:243:in `execute'
        from /usr/local/lib/ruby/gems/1.8/gems/safariwatir-0.1.1/./safariwatir/scripter.rb:68:in `highlight'
        from /usr/local/lib/ruby/gems/1.8/gems/safariwatir-0.1.1/./safariwatir.rb:10:in `click'
        from (irb):4
That's an important step forward, but I added something else this weekend just for fun.

Tell me, Mr. Anderson, what good is a phone call if you're unable to speak?

You can now interrogate any SafariWatir element ... and it will speak. After you gem install safariwatir, turn up your speakers and try this...

browser = Watir::Safari.start("http://redsquirrel.com/cgi-bin/dave/projects/watir/safari.watir.0.1.1.html")
browser.span(:id, "matrix_quote").speak
I'm not sure what a feature like this is good for, but I couldn't resist.

[/projects/watir] permanent link

Sun, 23 Jul 2006

Rails Acceptance Testing eBook

I am writing an eBook for Addison-Wesley (they call them shortcuts) on using Selenium and Watir to test Rails apps. Look for it in the October-November timeframe. If you have experience reports that you would be willing to share, let me know.

[/projects/watir] permanent link

Fri, 21 Jul 2006

SafariWatir 0.1.0

If you're a Mac-user who has been coveting the power and simplicity of (Windows/IE-only) Watir, your wait is over! It's your turn now! A pre-pre-pre-alpha of SafariWatir has been released. Go ahead and gem install safariwatir, fire up irb and go nuts...
require 'rubygems'
require 'safariwatir'
browser = Watir::Safari.new
browser.goto("http://google.com")
browser.text_field(:name, "q").set("safariwatir")
browser.button(:name, "btnI").click
puts "FAILURE" unless browser.contains_text("Watir on Safari")
There are tons of things missing from this release, but many of the basic Watir actions are in place. The critical missing piece is error messages: If you try to access elements that don't exist on the page, SafariWatir won't complain (yet).

[/projects/watir] permanent link

Thu, 20 Jul 2006

Watir at Rails Seminar

I will be showing how to use Watir to test Rails+Ajax apps at the Real-World Ruby on Rails Seminar in Silicon Valley on October 3. This time I shouldn't need to use Windows on Parallels to show off Watir on my MacBook Pro thanks to SafariWatir. :-)

[/projects/watir] permanent link

Sun, 16 Jul 2006

def_init'ly DRYer Ruby

I'm leading a study group at my current client. Nine of us are reading Ruby for Rails and get together every week with a projector to answer questions and hack away at some examples. I read a few chapters ahead so that I can provide exercises for the group to prepare for our meetings. I was reading chapter 5 today, it's fairly basic Ruby stuff, introducing the convenient and self-documenting attr_* methods. The following class is the example from the book, your typical brainless data holder...
class Ticket
  def initialize(venue, date)
    @venue = venue
    @date = date
  end

  def price=(price)
    @price = price
  end

  def venue
    @venue
  end

  def date
    @date
  end

  def price
    @price
  end
end
Using the attr_* methods, the mind-numbingly boring getters and setters can be collapsed into this more readable version...
class Ticket
  attr_reader :venue, :date, :price
  attr_writer :price

  def initialize(venue, date)
    @venue = venue
    @date = date
  end
end
Now, I've written constructors like that one more times than I care to remember in all sorts of languages. And everytime I do it, I feel a twinge of pain, it just feels silly to have to do that mapping of parameters to instance variables manually. When I'm writing Java, IDEA reduces this pain by generating most of it after a few ALT-ENTERs. But when I'm writing Ruby, repetitive constructs like these hurt even more, since that sort of repetition goes against one of the Ruby culture's most fundamental values: DRYness.

And thus the cousin to the attr_* siblings was born: def_init. By using def_init, the constuctor in the example could be reduced to...

class Ticket
  attr_reader :venue, :date, :price
  attr_writer :price
  def_init :venue, :date
end
I'm guessing that this functionality is already out there somewhere, so let me know if I've missed it. Here's the code that makes it happen...
class Class
  def def_init(*attrs)
    constructor = "def initialize("
    constructor << attrs.map{|a| a.to_s}.join(",")
    constructor << ")\n"
    attrs.each do |attribute|
      constructor << "@#{attribute} = #{attribute}\n"
    end
    constructor << "end"
    class_eval(constructor)
  end
end
It's interesting to note how Ruby and Java solve these sort of repetition problems differently. Java tends to solve repetition with excellent tools that generate code at development time, while Ruby tends to solve it through giving developers the power to generate code at runtime.

[/dynamic] permanent link

Thu, 13 Jul 2006

SafariWatir in development

If you haven't noticed, I'm a big fan of web testing tools like Selenium and Watir. As I prepared for my RailsConf talk (at RailsConf), surrounded by herds of Macs, I realized that Watir adoption in the Rails community was seriously not going to happen anytime soon without some cross-browser and cross-platform support. Without that support, I continue to recommend Selenium RC or Selenium on Rails to most Rails developers.

And yet I still find myself infatuated with Watir's dead-simple setup (gem install watir and you're done) and intuitive API. So ... <deep-breath/> ... inspired by the Mac-centric tendencies of most of the Rails frontrunners, I have launched the SafariWatir project on RubyForge. There's not very much there yet. You can open and close Safari, fill out text fields, click buttons and links, ask whether the page contains text ... oh, and you can click alert boxes.

I just discovered Apple's GUI Scripting integration with AppleScript, which makes it wonderfully easy to handle things that Windows makes incredibly difficult. (Apple provides GUI Scripting to facilitate universal access.) Watir (for IE) developers, you may want to look away, the following code could hurt...

tell application "System Events" to tell process "Safari"
	tell window 1
		if button named "OK" exists then
			click button named "OK"
		end if
	end tell
end tell
That's all it takes to click an alert button in AppleScript. I wrap that in Ruby-goodness and stick it behind the Watir API, and man, I think this project is going to just about write itself.

[/projects/watir] permanent link

Tue, 11 Jul 2006

Matz on Laziness

Yukihiro Matsumoto: I work very eagerly to be lazy.

[/links] permanent link

Sat, 08 Jul 2006

Selenium 0.7 RubyGem Update

As I mentioned in my talk at RailsConf, I needed to update the Selenium RubyGem to get it up-to-date. The gem is now available: gem install selenium. This will give you the latest release (0.7) of Selenium Core. In previous Selenium gems there were a few crufty Ruby files in there, but these have now been extracted to Selenium Remote Control.

This update is mostly for Jonas and Bret.

[/projects/selenium] permanent link

Adding a month to a Ruby Date object

It must be the Perl Hacker in me that enjoys this sort of syntax...
    @event.date >>= 1
Any idea what that does? Well, Date has a method called >> which returns the Date plus the specified months. But I wanted to reassign the Date immediately, so I tried >>= and it worked. If anyone has a cleaner way of doing this, email me.

[/dynamic] permanent link

Fri, 07 Jul 2006

Let me Drive! A Pairing Story

I've been coaching a team of developers for a couple months. We have had a bunch of new people join the team while others have rolled off onto other projects. This has presented a lot of opportunities to redefine things, along with a bit of chaos. It's been great to see that a number of these new hires are women, which on an XP team tends to work well, since women tend to be more interactive. That said, some of these folks can also be fairly passive, which can be a challenge when they're pairing, because the more dominant personalities among us often grab the keyboard and never let go until someone suggests otherwise.

Today I was developing a black-box regression test with one of these more recent hires. We were about to rip apart a bunch of code across an entire sub-system and needed some high-level tests to ensure that we didn't change any behavior. Well, being the hyperactive-Ruby-hacker that I am, I was a bit overzealous with the keyboard. It was a pivotal (and exciting) moment when my soft-spoken pair programmer quietly berated me for hogging the keyboard and took it back. I was chuckling at myself the rest of the day as I watched her grow more comfortable with Ruby and the Watir API.

[/xp] permanent link

Ruby on Rails TDD Bootcamp

Just thought I'd plug Obtiva's initial venture into the world of Ruby on Rails. If you're interested in learning Rails with a strong emphasis on TDD, take a look. Ruby Primer and Ajax on Rails add-ons are available.

[/dynamic] permanent link


powered by blosxom