Episode 98 - 06 Sep 2017
Way back in November last year, I did an episode on BDD - Behaviour Driven Development.
It did rather well: 9,200+ views so far.
Alas, it contained a big fat mistake. And to fix it, I'm going to need your help. Can you do better than this?
Given the account is in credit And the card is valid And the machine contains cash When the Customer requests cash And the card is returned And the customer withdraws the card Then account is debited And the cash is dispensed
And remember to grab your copy of the TDD vs BDD Cheat Sheet
This is a cash machine. Otherwise know as an ATM.
I must have used one of these things a thousand times.
And the process is always the same.
So when I came to do an episode on Behaviour Driven Development - BDD - and did the “classic” ATM example, how did I manage to screw it up?
And this is my first ever video erratum.
And yes, I did have to look it up.
And when I did I found an even more interesting word:
Corrigendum
So welcome to this corregendum.
A few months ago I did a video on BDD - Behaviour Driven Development. And I used an example of a cash machine. You might know it as a an ATM.
Truth be told, this was laziness on my part.
This is Dan North.
He’s the guy that coined the term Behaviour Driven Development.
And, presumably, the abbreviation BDD.
(Please don’t make the mistake of calling it an acronym. It’s not an acronym.)
And this is the post that kicked it off “Introducing BDD”.
And way way down the page is an example of what Dan refers to as “the classic example of an ATM machine”.
Given the account is in credit And the card is valid And the dispenser contains cash When the customer requests cash Then ensure the account is debited And ensure cash is dispensed And ensure the card is returned
The version that appeared in my video was suspiciously similar:
Given the account balance it £100 And the card is valid And the machine contains enough money When the Account Holder requests £20 Then the Cashpoint should dispense £20 And the account balance should be $80 And the card should be returned
And you know what?
It was months before anyone pointed out that the sequence of events… isn’t quite right.
//Missing text
I should say that since then, several of you have made the same observation.
Then I hit a problem: it wasn't as easy to fix as I'd hoped.
No problem, I thought: I’ll just Google it.
I discovered something interesting: Dan North’s classic example is all over the web.
I hunted through page after page…
The exact same example each time.
It seemed I would be forced to engage brain after all.
This was my first attempt:
Given the account is in credit And the card is valid And the dispenser contains cash When the customer requests cash Then the card is returned When the customer withdraws the card Then the account is debited And cash is dispensed And the card is returned
It's a bit messy. Not sure there is a
Given > When > Then > When > Then
structure in bdd!
Then I wondered if there were two scenarios:
Given the account is in credit And the card is valid And the dispenser contains cash When the customer requests cash Then the card is returned
And the second:
Given that (lots of good stuff has happened) When customer withdraws the card Then the account is debited And cash is dispensed
Hmm. That feels like two incomplete scenarios. What I need is something that’s… whole.
How about this:
Given the account is in credit And the card is valid And the dispenser contains cash When the customer requests cash And the card is returned And the customer withdraws the card Then the account is debited And cash is dispensed
What do reckon?
Is that it?
Let me know in the comments here
If you haven't done so already, now would be a great time to grab this rather lovely cheat sheet
The TDD vs BDD cheat sheet.
Watch "Bad Behavior (Driven Development) + CHEAT SHEET" on YouTube.