It’s easy to write software. It’s harder to write software that’s simple, elegant, working and important. Examples help to drive conversation, avoid ambiguity, eliminate waste, make estimates more accurate, clarify design and produce software that matters. Participants will develop a small game in a Renga (taking it in turns), adding examples of desired application behaviour at both a system and unit level, while learning BDD concepts. Find out how BDD’s outside-in approach can reduce redundancy, allow good designs to emerge, and maintain English-readable code down to the lowest level.
I’ve been using the Game of Life to teach BDD for the last couple of years. It’s short, simple and very visual. The code for everything apart from the engine already exists (http://lunivore.com/code). Following the feedback in comments, we’re going to show how JBehave 1.0 does BDD first (thanks again for feedback), then follow it up with ways of doing the same thing using JUnit 4.4. There are some established techniques which are already used to do this on commercial projects. We’ll introduce a couple of simple new tricks, brought to you from the sandbox of JBehave 2.0.
Brian suggests we’ll have to deftly tease participants into using BDD’s terminology. Fortunately both Dan and I have huge amounts of experience at doing this!
(JUnit 4.4 wasn’t out when JBehave was written. While it was impractical to use JUnit 3.8 for BDD, JUnit 4.X allows greater freedom… so much so that we’re taking a new look at what we can do with JBehave in combination with JUnit, for JBehave 2.0. Think of this as a sneak preview.)
We give a brief overview of BDD, using the examples in JBehave to show how the principles of BDD can be carried into the code. JBehave’s examples include a fully BDD’d Tetris game. We explain how the code evolved from the scenarios, and demo both automated scenarios and unit-level code. We also show how the language of examples makes it easy to discuss the code in domain terms.
We will also explain why we’ve chosen to use JUnit for the exercise, instead of JBehave.
We provide an existing code base, consisting of:
Participants are invited to bring their examples from the Examples Workshop, or to make them up as we go along (for reasons of time we’ll help them avoid some of the changes that need to be made to naive examples as each rule is introduced).
Participants take it in turns to either add a new example or scenario, or make an example work (a Renga is like ping-pong pairing with multiple people). Dan and I will make the occasional suggestion, give help if needed, and explain BDD techniques as we go.
We will encourage participants to:
Throughout the session, we’ll address any points at which participants deviate from BDD’s practices. We’ll discuss what benefits might result from using eg: given / when / then / should, and help participants to talk about the code in the language of the domain. We’ll also introduce new concepts and ways of thinking about BDD (such as “outside-in” or “bug-driven development”) as we progress. Previous workshops using the game of life have involved a great deal of discussion. The renga is deliberately intended to give everyone who wants a turn at coding, while ensuring plenty of time for further discussion and Q&A.