Chris Donnan : Programming - Brooklyn Style
software, trading, family, fun
Posted programming on Sunday, July 22nd, 2007.
User Stories for requirementsÂ
Go read this right now: What’s in a Story?
We/ I am using user stories as the primary format for product backlog items, features .. er … requirements. It is hard - but good. I have more or less done this for some time.
I have been looking at some of the tools from the BDD community lately. I am a huge TDD guy. I am sure many of my collegues wish I was a bit less so - I am the preacher in my current firm - it is part of my role to get folks doin’ that thing (hard by the way). In any case - I have been looking @ both NUnit.Behave the past few days, as well as NBehave - 2 different frameworks for a sort of story driven development. I wil still admit I am not 100% sold on the BDD pitch - but these tools do seem to ring with me.
You start with a story and some acceptance cases (from Introducing BDD):
Story:
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closedAcceptance Cases:
Scenario 1:
Account has sufficient funds
Given the account balance is $100
 And the card is valid
 And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
 And the account balance should be $80
 And the card should be returned…
Then you codify these acceptance cases so you can verify when your story is satisfied.
…but now an aside on …
DSLs (Domain Specific Languages)
DSLs are another current “hot topic”. The dynamic language folks - especially the ruby ones have done a great job of making software where the code looks more and more like english.
..and now an aside on…
Fluent InterfacesÂ
Fluent interfaces enable a DSL feel in a “heavy” language like C# or java (as opposed to ruby or python). There has been a rash of fluent interface madness for some months now - everyone is talkin’ about ‘em. I admit I was an early skeptic - too many dots scares me and makes me think of LoD violations. When I started to “get it” a bit and see fluent interfaces as a DSL-ish thing - it clicked some more.
Dave Larabee has a recent and much ref’d article Ordered Fluidness from a week or 2 ago - this is a good deeper read.
Back to NUnit.Behave and NBehave
As I mentioned above - the gist of these tools is to enable you to code your storys and acceptance critera for your stories.
Lets look at this in a ruby - pretty close to a real DSL it looks:
Â
Now look at how the Fluent Interface lets C# look sort of like a DSL in NUnit.Behave:
From here (More Fluent Interfaces for NUnit.Behave )

While some of the _ in the methods is a bit ugly- moreover that is pretty nice. This is a work in progress it seems - but it seems be on the right path.
RBehave is a little more “classy” - not so DSL-ish. After installing the current (also very early on) RBehave - it just seems to lack the DSL feel that the former has. In stead of doing that Fluent Interface thingy - you have to make a bunch of disconnected classes that tie together to do the same thing - it is just more difficult to follow… For now - I will track along both projects - but it seems NUnit.Behave is headed 100% in the right direction.
Enough babble - more later - I am off to prep for Gabe’s 5th birthday party today - FUN!
Chris
No Responses to “NUnit.Behave, NBehave, DSLs, Fluent Interfaces - and other popular gibber jabber”
Comment on this post below
You must be logged in to post a comment.
You can leave a response, or trackback from your own site.








Great post.
About NUnit.Behave:
Don’t you think it’s easier to read the method names with the underscores present? Sometimes camel casing can be a pain to read.
Also, people like Scott Bellware and Joe Ocampo have written tools to parse their tests and render an HTML file that can be handed to a user and they can read it. Underscores is easier to work with and read.
Just my $0.02
Thanks. It just looks odd to me. In C# specifically - i just think it is ugly - and PascalCase just seems natural to me. That said - I can be an opinionated fool
so it is fine to have it another way. WRT having _ in HTML files, it is easy enough to separate out PascalCasedTerms as it is to separate out _ delim’d terms to write on a screen. Again - whatever works - it just seems off to me.
-Chris