I like to try multiple different approaches to solving a problem to see how they compare. I might learn something from one approach that I could apply to another. As an example, I created an alternative approach to calculations with fractions. The fraction idea comes from J.B. Rainsberger’s class on Test Driven Development. It is a great demonstration of TDD.
In this example, I’m going to use Gherkin as the specification language for the customer facing behavior For applications where the external behavior and its component parts are specified by the customer and/or stakeholders, having examples in Gherkin can dramatically decrease the communication impedance between the customer and the developer. PDF is here. HTML is here.
Some agile practice articles discuss how individuals should be organized into teams and work
collaboratively. Other articles describe how product backlog items/features and sprint backlog
items/stories/tasks should be estimated and scheduled. In this article, the flow perspective focuses on how customer or business value is delivered. This flow is sometimes shown with value streams, story maps, customer journeys, workflows, or other means. Understanding and making the flow visible can help with organizing the other views of agility. The article in html is here. The article as a PDF is here.
There is a flow from external requirements to internal tests. Requirement Driven
Development (RDD) (aka Behavior Driven Development / Acceptance Test Driven
Development / Specification by Example) focuses on the external behavior.
Test Driven Development focuses on the internal behavior that creates the
external behavior. There is an overlap between the two. TDD can go all the
way up to external behavior. RDD can differentiate into more detailed
behavior. Go here for html. Go here for PDF.
Software applications should satisfy the requirements. To put it in reverse, requirements drive the development. Every requirement should have a test for it that checks that the requirement is implemented properly. Any code that does not satisfy a requirement (functional or non-functional) is not needed.
Read this blog as PDF. Read this blog in HTML.
This kata revolves around a common domain term – money. Money appears in many applications, so the code from this kata might be adapted to those applications. Although it uses a dollar, it’s easily changeable to the currency of your choice by just replacing the currency symbol. Since requirements /tests written in Gherkin are implementation independent, you can implement this in any language. Some languages may be easier than other since they have more extensive libraries. Programmers can try multiple implementations and then have discussions as to the relative merits of each one.
The full kata in a PDF. The kata in html.
The kata is released under the Creative Commons copyright.
In reviewing a book, I was reminded about the Gilded Rose kata. It revolves around some legacy code that has no tests. You need to make some changes to the code to support a new requirement. The kata was created by Bobby Johnson (http://iamnotmyself.com/) and updated by Emily Bache (http://coding-is-like-cooking.info/).
A detailed explanation of the Gherkin approach is in this PDF. An html version is here. The code that the PDF references is at https://github.com/atdd-bdd/GildedRose . There is one function that has not been refactored yet. It’s left as an exercise to the reader.
You can compare this solution to other solutions to the Gilded Rose kata to see alternative ways to approach this problem.
Gojko Adzic asked for opinions in his blog “How to Specify Something Should Be Random. He presented alternative scenarios and asked for your choice.
The situation he described is having a robot’s chat response appear like it comes from a human being. There could be multiple levels of tests associated with this requirement. Let’s take a look at these levels and along the way give my choice(s) for an answer. Continue reading Layers of Scenarios and a Reply on Randomness
“How to organize feature files?” was a question asked by Gojko Adzic in a recent blog. He presented several options and then asked for responses. The options included grouping them by user story, by capability and level of detail. This question has often come up over the past years in the workshops that I teach.
Continue reading Organizing Your Feature Files
A blog question on relative dates by Gojko Adzic triggered a blog post by Seb Rose. The two blog posts showed there are many shades of gherkin. I’d like to use the example in those two posts to demonstrate a couple of facets of scenario decomposition. This uses a slightly different shade than Seb’s.
Continue reading Decompose Scenarios for Simpler Scenarios
A blog on specflow.org talked about ways to document scenarios for a business rule. It reminded me about some aspects of blog wrote a few years ago called Six Shades of Gherkin. Here’s the business rule that was used as the example in specflow.org blog:
A volume discount rule provides 10% off for purchases between 5 and 10 items, 15% for purchases between 10 and 20; and 20% above that.
One of the issues with business rules is making sure they are understood by the entire triad (customer, developer, tester). In this example, what is the discount for 10 items? One way to document is to use a scenario outline that gives the results for each side of each breakpoint. Another important value is documenting the results at the limits and beyond. Continue reading A Few Shades of Gherkin For Business Rules