Improving the language of Feature Files

This is the first in a series of posts which are concerned with software development, specifically with the writing of Feature Files. I started this blog because I imagined that I had something interesting to say on a number of subjects. On most of these, my musings are of limited appeal, and will doubtless be lost amongst the vast quantity of more well-informed or more eloquently expressed opinion. On this particular subject though, I discover that there is relatively little published material, so I feel that I might be doing a service to others in writing about what I know, as well as satisfying my desire to commit pen to paper on whatever comes to mind.

My particular concern is the use of Feature Files as long-lived documentation that is valuable to multiple stakeholders. Here’s a diagram of the commonly regarded “Holy Trinity” of functions of a Feature File.

holy trinity.png

This post is mostly about the background to my particular interest in the largest of the above circles. For the last twenty or so years, I’ve worked in Financial Services, in Investment Banking. Like many in my field, the years since 2008 have been concerned with satisfying the increasing amount of regulatory oversight of our activities. My first involvement in this area was in writing a system to satisfy the regulatory requirements to protect client assets held by the bank in the event of its demise.

Regulators are not only concerned that firms like mine do the right thing, but also about how they do it. Part of this concern behoves us not only to to demonstrate that we understand how our systems behave, but also to provide an audit trail of documentation proving that understanding.

The system in question was one of the first that we developed using a newly adopted agile development methodology, a key part of which was the definition of the system behaviour in terms of Feature Files.

We knew in advance that the regulators and auditors would descend upon us as soon as the system was operational, and we also knew that their first demands would be to provide the standard documentation around around a project of this type – a BRD, functional and technical specifications, all of the usual rotten artefacts of an old-school SDLC. We would only have our Feature Files to fall back on, so we had to make them good!

This is where my interest in the use of Feature Files as living and lasting documents stems from. My concern is primarily about making feature files as readable and understandable as a finely crafted Word document, so that months or years after their initial implementation they still stand up as accessible descriptions of system behaviour.

Enough already with the preamble. So that this first post is more than just an essay, let’s try an exercise. Here’s an example from the Cucumber documentation describing the scenario outline gherkin syntax:

starter.png

All well and good. Presumably, if you have read this far, you already know something about Feature Files, and so can understand what’s going on here. But just for the sake of argument, try putting another hat on – say the hat of a relatively technically illiterate reader. Ask yourselves these questions:

  • What does the scenario outline header tell you?
  • How do the “Given, When, Then” steps actually read in english?

Fair enough – this is a feature, illustrating a basic subtraction algorithm, that would probably never be necessary in the real world. However, suspending your disbelief for a moment, how would you rewrite this scenario to make it more easily understandable to the casual reader?

There are no right or wrong solutions to this exercise. My point is that the writing of scenarios in a feature file to make them useful as long-lived documentation is an art rather than a science. To illustrate that point, I provide two possible solutions which have  been provided when I have workshopped this subject.

The first takes the example as given, adjusts the example column headers to express the problem (simple subtraction) in a domain language that suits it, and makes some simple changes to the step wording to accommodate those changes. It also adds a more meaningful scenario header:

solution1.png

The second example takes an entirely different approach. Understanding that the use of more than one example is redundant in this case, it proposes a different scenario style entirely, using what I call the “narrative paragraph” style:

solution2.png

Scenario styles will be the subject of the next post in this series. For the moment, I hope that this exercise will encourage you to start thinking more about the language of your Feature Files.

My Mother-in-Law’s Everyday Red Lentil and Tomato Dal

I have been a home cook since my teens, and had a thorough introduction to Indian cuisine through my father. He was a branch bank manager in Cambridge, and had been selected – by chance I imagine – by the prospective owners of the first Indian restaurant in the city. He was happy to help them start the business, and thereafter every new Indian restaurant that opened brought their business to him. He brought his business to them too, and we regularly visited each of them and enjoyed their hospitality and papadums!

My first, and late, wife’s family were originally from Hyderabad, India but moved to London in the early sixties, where my wife was brought up. The family were sceptical about the Englishman that their daughter brought home to meet them, but my mother-in-law was a marvellous cook, and I knew the best way to ingratiate myself would be to take an interest in the kitchen goings-on.

Over the following years, I learnt quite a few recipes from my mother-in-law, but this was the first, and is certainly the most delicious. It’s a basic dal made with red lentils, tomatoes and most importantly, curry leaves. Don’t even attempt to cook this dish unless you have these, preferably fresh ones. I’ve cooked this regularly as my children have grown up, and it’s one of our comfort foods. It can be eaten over rice, or mopped up with a chapati or paratha. It can be the main event, or a side dish. This recipe makes enough to feed three or four people as a main, or more as a side…

Ingredients:

For the dal:

1 cup red lentils, thoroughly rinsed.

3 cups water

1/2 a clove (or a small whole clove) of garlic, sliced

3-4 curry leaves

1/4 teaspoon turmeric powder

some chopped tomatoes (1 or 2 medium sized ones, half a dozen cherry or baby, or half a can of drained chopped plum tomatoes)

For the tadka:

3 tablespoons of vegetable oil

1 tsp cumin seeds

1 teaspoon black mustard seeds

3 or 4 dried small chills (or some chilli flakes will do)

6 -7 curry leaves

Method

put the lentils and the water in a saucepan, along with half a garlic clove, sliced, 3 or 4 curry leaves, the turmeric and the tomatoes. Bring it to the boil over a moderate heat,

IMG_2706.jpg

and when it comes to the boil, skim off the foam that may form and reduce to a simmer.

IMG_2707.jpg

IMG_2708.jpg

 

 

 

 

 

Simmer  for around 15 to 20 minutes until the lentils have cooked and broken up. The resulting Dal should be soupy,  with the lentils settled at the bottom and a layer of liquid at the top. Add some more water if this isn’t the case.Now give it a quick stick blend. 5 seconds or so should do. You want to break up the remaining shape of the lentils, but there should still be some texture to the dal.

IMG_2710.jpg

Now make the tadka. This is some oil with spices fried in it, which we’re going to add to the dal to give it the finished flavour. Here’s the ingredients I’ve assembled, and the dish I cook it in. It’s a small karahi, about 6 inches across, but any small frying pan or saucepan will do.

IMG_2711

IMG_2712.jpg

 

 

 

 

 

Heat up the oil, and then drop in the mustard and cumin seeds. They should fizz away if and when the oil’s hot enough. Once they’re fizzing, add the garlic, curry leaves and garlic slices. fry for a minute or maybe less, until the garlic slices are just browning at the edges.

IMG_2714.jpg

When its like this, take it off the heat, and then CAREFULLY pour the oil and spices into the dal, which should also be off the heat. It will spit and fizz when you do, so keep your face away when you do this.

After, put the dal back on a gentle heat and stir in the tadka. Heat through and taste, now adding salt to your liking. about 1/4 teaspoon of table salt would do it for me, but try it and adjust it to how you like. As you cook it now, be careful to stir often, as the lentils will settle and may stick to the pan otherwise.

It should look like this at the end. As I said before, this dal can be poured over rice, or mopped up with a chapati or paratha. Either way, it’s delicious!

IMG_2715.jpg