Thursday, September 11, 2008

Behave!

This is a great time of the year! I always loved September.  It is a bit cooler,  American and world football begin and school begins.  I will never forget the smell of new crayons in grade school, the gleaming halls and lockers in high school, the trees changing in South Bend and the never ending new challenges in Pittsburgh as first year courses led to thesis, led to comprehensives and finally to dissertation.  Nowadays it means new students for the fall term and freshly corrected log books from the summer term.  This summer term resulted in some truly superb entries.  Here's the first from Joe Rafaniello on Behavior Driven Development, a new technique in agile methods that I currently do not cover in my courses.  I am still not a big fan of specification languages but many folks use and love them and any software engineer should definitely give them a try to see if it works for them.

A relatively new concept in the agile community is behavior driven development.  I have recently researched it for work and feel it is a great way for developers to deliver programs that exhibit all behaviors required to meet customer requirements and at the same time have tests that back up the code.
    In BDD, a developer writes the test or specification first just as in test driven development.  In contrast to TDD, BDD is written in a language that looks more like English and lowers the barriers to entry for customers or project managers interested in what the code does.  This can be very convenient when small teams develop directly with their clients input.  BDD in Ruby is done using RSPEC and looks like this:

# bowling_spec.rb
require 'bowling'

describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it "should score 0 for gutter game" do
    20.times { @bowling.hit(0) }
    @bowling.score.should == 0
  end
end
(http://rspec.info/)

The idea is that the developer writes the specs before the code.  The spec is run and fails the test. The developer then writes the simplest code to satisfy the spec and now the spec passes. 
    The benefit of RSPEC type languages are that even someone with minimal programming experience can understand the basics of the specifications.  Whenever the business side and programming side can move closer to each other through communication, the better odds of delivering the product on time and as specified.

If you are interested in rspec, check out the site Joe listed here.  if you have time add a note on your opinion of specification languages in general or RSPEC in particular.  The title was a quote from Austin Powers.  I could not resist.  Later!



No comments:

Post a Comment