Scenarios using custom DSLs

One of my clients recently asked me how often I use Cucumber or JBehave in my own projects. Hardly ever, is the answer, so I want to show you what I do instead.

The English-language Gherkin syntax is hard to refactor. The tools form another layer of abstraction and maintenance on top of your usual code. There’s a learning curve that comes with them that can be a bit tricky. The only reason to use the tools is because you want to collaborate with non-technical stakeholders. If nobody outside your team is reading your scenarios after automation, then you don’t need them.

There may still be other reasons you want the tools. They’ll be more readable than the code I’m about to show you. Dynamic languages are harder to refactor anyway; I work primarily with static typing. Maybe you want to take advantage of hooks for your build pipeline. Maybe you already know and feel comfortable with the tools. Maybe you just really want to learn the technique. That’s OK. But you don’t need them.

So here’s a simple alternative.

Have some conversations, and write down the examples.

I like it when the developers do this, and get feedback on their understanding. Writing it in semi-formal Gherkin syntax is pretty useful for helping spot missing contexts and outcomes. All the usual goodness of Three Amigos conversations still applies.

Find a capability, and the thing that implements it.

Your application or system probably has a number of things that it enables people or other systems to do. We’re going to be using a noun that matches those things as a way of starting our DSL. Here are some examples:

  • Buying things -> the basket
  • Making trades -> a trade
  • Commenting on an article -> a comment / the comments
  • Doing banking -> the account

You may find the language is a bit stilted here (I did say the English was clearer!) but that’s a trade-off for the ease of getting started with this. You might find other things which make more sense to you; it’s sometimes possible to use verbs for instance.

  • Searching for a car -> I search

You’ll get the idea in a moment. Each of these is going to be the stem of a bit of code.

Start with comments in the code

Sometimes I like to just start with my scenario written in comments in the code. For each step, think about whether the step has already happened, is the thing that triggers some interesting behaviour, or is the outcome of that behaviour. Add Given, When or Then as appropriate:

    // Given an article on Climate Change
    // When I post a comment "This is a really conservative forecast."
    // Then it should appear beneath the article.

Add the Given, When or Then to your stem, and…

  • Given the basket…
  • When the trade…
  • When a comment…
  • When a search…
  • Then the account…

…construct your steps!

Now we’re in code.

GivenAnArticle().on("Climate Change")

GivenTheBasket().contains("Pack of Grey Towels")

WhenTheTrade().isCreated()
    .withCounterparty("Evil Corp")
    .forPrice(150.35, "USD")
    .....
    .andSubmitted()

WhenISearch().For("Blue Ford Fiesta")

ThenTheAccount().shouldHaveBalance(15.00, "GBP")

You can see that trading one is using a builder pattern; each step returns the trade being constructed for further changes, until it’s submitted. I sometimes like to use boring, valid defaults in my builder so that these steps only call out the really interesting bits.

I normally suggest that a “When” should be in active voice; that is, it should show who did it. If that’s important, add the actor.

WhenTheTrade().isCreated()
    .....
    .andSubmittedBy("Andy Admin")

or

WhenTheTrade().isCreated()
    .by("Andy Admin")
    .....
    .andSubmitted()

Active voice would normally look more like:

When("Andy Admin").createsATrade()
    ....
    .andSubmitsIt()

But now our “When” is ambiguous; we can’t tell which kind of capability we’re about to use, so it makes it really, really hard to maintain. It’s OK to use passive voice for DSLs.

As I construct these, I delete the comments.

Sometimes I like to just put all the detailed automation in which makes the steps run, then remove the duplication by refactoring into these steps. (Sometimes it’s enough just to just leave it with detailed automation, too, but at least leave the comments in!)

Pass the steps through to Page Objects; use the World for state

You’ll probably find you need to share state between the different steps. I normally create a “World” object, accessible from the whole scenario.

Each of the stems you created will correspond to one or more page objects. I like to keep those separate, so my steps in the DSL don’t do anything more than just call through to that object and return it.

Here’s an example of my scenario object for a Sudoku solver:

public class Scenario
{
        private readonly SudoqueSteps _sudoqueSteps;
        private readonly CellSteps _cellSteps;
        private readonly HelpSteps _helpSteps;

        private World _world;

        protected Scenario()
        {
            _world = new World();
            _sudoqueSteps = new SudoqueSteps(_world);
            _cellSteps = new CellSteps(_world);
            _helpSteps = new HelpSteps(_world);
        }
        
        protected CellSteps WhenISelectACell{ get { return _cellSteps; }}

        protected CellSteps ThenTheCell{ get { return _cellSteps; }}

        protected SudoqueSteps GivenSudoque{ get { return _sudoqueSteps; }}
        
        //...

        protected HelpSteps WhenIAskForHelp { get { return _helpSteps; } }

        protected HelpSteps ThenTheHintText { get { return _helpSteps; } }
}

It does get quite long, but it’s pretty easy to maintain because it doesn’t do anything else; all the complexity is in those underlying steps.

And here’s how I use it:

    [TestFixture]
    public class PlayerCanSetUpAPuzzle : Scenario
    {
        [Test]
        public void APlayerCanSetUpAPuzzle()
        {
            GivenSudoque.IsRunning();
            WhenISelectACell.At(3, 4).AndToggle(1);
            ThenSudoque.ShouldLookLike(
                "... ... ..." + NL +
                "... ... ..." + NL +
                "... ... ..." + NL +
                "           " + NL +
                "... ... ..." + NL +
                ".1. ... ..." + NL +
                "... ... ..." + NL +
                "           " + NL +
                "... ... ..." + NL +
                "... ... ..." + NL +
                "... ... ..." + NL);
        }
    }

Full scenarios here.

This one was written in plain old NUnit with C#. I’ve done this with JUnit and Java, and with JUnit and Kotlin. The examples here are only from toy projects, but I’ve used this technique on several real ones.

There are lots of tools out there which help you to construct these kind of DSLs; but I’ve found they also come with their own learning curve, constraints, maintainability issues etc.. This is a pretty easy thing to do; I don’t think it needs anything more complicated than I’ve put here.

It’s also very easy to refactor overly-detailed, imperative scenarios, of the kind created by lots of teams who didn’t know about the conversations, into this form.

It’s easy to move to the BDD tools if you need them.

With your Page Objects already in place, it’s pretty quick to get something like Cucumber up and running and make the step definitions call through to the page objects exactly as you were before, with just a little bit of refactoring of method names.

It’s a lot harder to move from Cucumber and regex to a DSL.

Chris Matts once had some great wisdom. “If you don’t know which technology to choose, pick the one that’s easy to change. If it’s wrong, you can change it.”

This is the one that’s easy to change, so I tend to start with this. And sometimes it doesn’t need to change.

 

 

Posted in bdd | 8 Comments

Off the Charts

If you’re following me on Twitter, you’ll have noticed that the amount I’m talking about the environment and climate change has ramped up recently. I want to explain why, and why this is probably the most important blog post I’ve ever written.

For GOTO Amsterdam, the organizers asked if I could talk about the 4th Industrial Revolution (I may write a blog post on that later). While I’m familiar with the concepts in the 4th (possibly actually the 6th) IR, I needed to know a little bit more about the history of Industrial Revolutions in general to make a good talk. So a few months ago, I started researching.

Iron and steam. Steel forges and railways and ocean-going ships. Electricity and telephones and computing and the technology age that we now currently enjoy. Movement and machinery and connectivity. The automation that started with the textile mills of the UK has spread world-wide.

It all needs power. Lots and lots of power. Those of us in the tech industry use a hell of a lot of it; in our work, our play, and our travel. Our computers and the internet require power. Those hot laptops and graphics cards are evidence of how much power we use. The aircon that keeps our offices cool. Our cars, our flights, the industry that makes our phones and tablets and all the other tech…

It all needs power.

So I started researching the effects of that power.

I hadn’t actually read the IPCC’s report before. There’s a summary of it for policymakers that’s a bit long.

Until this year, I figured the policymakers had probably read it. They had to be working on something that was appropriate for the urgency, right? But the Extinction Rebellion movement keeps growing… is it just people panicking over nothing, or is that sense of urgency really justified? Does Greta Thunberg, the 16-year-old who’s spoken most passionately about her own future, really mean it when she talks about the collapse of civilization as we know it?

Well, the IPCC’s got some nice pictures to make it easy for us. Here’s two of them. They’re on page 11 of that summary I’ve already linked.

IPCC report: How the level of global warming affects impacts and/or risks associated with the Reasons for Concern (RFCs) and selected natural, managed and human systems

So this is why they’re asking us to stay below 1.5C.

I thought 1.5C might be, you know, kind of OK. But it turns out even at 1.5C we’re destabilizing the arctic (bye-bye, polar bears), probably the Western Antarctic ice sheet, losing most of the warm-water corals with their rich ecosystem, turning some places into famine-stricken deserts, and flooding others. You know, more than they already are. You can see the grey bar representing 2006-2015 on that chart.

1.5C turns out to be… still pretty bad.

At 2.0C, as well as the effects being horribly red-looking across the board, we’re entering that place where the feedback cycles start kicking in. You know, more than they already are. Here’s a picture from ClimateVictory.org that shows the basics of what that looks like.

So we’d really, really like to stay below 1.5C if we can, because 2.0C is not looking good. 2.0C is looking, well, pretty devastating.

So how are we doing?

Here’s the Independent’s report, based on a number of existing models. I’m just going to quote it, because there’s a key phrase in there, and the fact that it exists is ridiculous.

Based on lack of meaningful global action to rapidly extinguish all greenhouse gas emissions within the next decade, the authors sketch out a scenario in which global emissions peak in 2030.

In this case, using several existing studies, they hypothesise average global temperatures may reach 3C above pre-industrial levels by 2050.

Scroll back up. Can you see 3C on those charts?

I think that’s the point where scientists just throw their hands up and beg everyone to grow the f&*$ up. Actually, that’s Bill Nye doing that, right there. And you can hear everyone laughing, because Bill Nye swearing is incongruous with his normally family-friendly presentation and incongruity makes us laugh, but it isn’t funny. It isn’t funny at all.

3C is off-the-charts catastrophic.

And we’re looking at 5C by the end of the century, at least. 5C’s unimaginable. At 5C and above, things start to get apocalyptic. If it isn’t an existential threat for humans entirely then it will certainly, as Greta Thunberg says, be the end of civilization as we know it. António Guterres, the Secretary-General of the UN, said this week that “We are in a battle for our lives.”

What does that look like?

We’ve already started to see it. It looks like Chennai, India’s 6th biggest city, running out of water. It looks like police using tear-gas on peaceful protesters, in a country where the temperature hit 45C this week. It looks like animals going extinct, at a rate that’s faster than anything since the meteor impact wiped out the dinosaurs. It looks like insects disappearing and the failure of ecosystems world-wide that results.

It looks like that, only more, and worse, everywhere. Oh, and the sea-level rise will cause storm-surges (which will be more frequent) to flood most coastal cities, and probably London too.

So what do we do?

1. Change your personal priorities.

Most of us who are environmentally-minded are used to thinking, “How can we live our life the way we want, and still be kind to the world?”

We need to change this round. “How can we be kind to the world, and still live our life the way we want?”

That means doing whatever you can, even if it makes you uncomfortable. Take the train instead of flying. If you have to fly, carbon-offset your flights. Carbon-offset everything. This site by fellow coach Henrik Kniberg and friends, GoClimateNeutral.org, makes it easy.

A zero-carbon world doesn’t have to be an awful one. The more we invest in it, the more the infrastructure around it changes to support it, and the easier and cheaper it gets… and the more normal it gets, until hopefully the outliers are shamed into joining the rest of us.

2. Make a difference, or support people making a difference.

Join the protests. If you can’t join the protests, fund the protests. If you can’t fund the protests, facilitate a workshop for them or help out with a website or even just offer a bit of moral support. (Shout-out to Sal Freudenberg for her inspiration; she will have even more suggestions.)

Plant a tree. Change providers. Use green electricity. Get an electric car. Or better yet, a bicycle. Switch to the Ecosia search tool. Don’t like my suggestions? Great! Make better ones.

3. Make a noise.

Do not go gently into that good night. It won’t be good, and it won’t be gentle, and by the time that starts to make itself felt in your life, it will probably be too late. Shout about it. Those of us in technology are more connected than anyone else. Shout about the products making a difference. Shout about the awesome people doing good things.

But most of all, shout about the urgency. Shout about how we need to do something now.

They say the best time to plant an oak tree was 20 years ago, but the second best time to plant it is now. It’s already too late to save everything.

Let’s save what we can.

Posted in life | 4 Comments

On Multiple Givens, Whens and Thens

I wrote this as a reply to user RHarris’s question on StackOverflow, but thought it might be easier to find here too. The login scenario and the access record here are adapted from their question.

What contexts should we include in a scenario?

Scenario 1: A user signs in with valid credentials

Given the Sign In page is displayed
When the user enters a username and password
And the user submits the request
Then the user should be directed to the Home page

I find it helps to think of scenarios not as tests, but as living documentation that helps to illustrate how the system behaves and why that’s valuable.

If you can tell that the user isn’t locked out and isn’t disabled in that first scenario, then you don’t need to include those steps.

For something like logging in with an active, enabled account this is obvious, but it might not be for something like a trader staying within their trading limits, or a fetal heartbeat running at a healthy rate, or a comment that hasn’t yet reached the reporting threshold. You can decide whether to include those kind of contexts pragmatically.

I prefer though to move documentation that doesn’t change or doesn’t change very often, like core domain concepts, outside of the scenarios. Perhaps it can be at the blurb at the top of the scenario file, or on a team wiki somewhere that new joiners get to read before they code. It doesn’t have to be in the scenario.

(Obviously you would need to include the contexts which cause the failure in any failure scenario though!)

What about side-effects and other outcomes?

...
Then the user should be directed to the Home page
And the logs should record their access.

All outcomes that matter do so because at some point, they become visible or have effects beyond the system whose behaviour is covered in the scenario.

For instance, when I get money from a cash machine, my account is also debited. I might not see that as part of the behaviour, but it does have to happen. That’s because there’s another stakeholder involved in the scenario – the bank.

Or perhaps, when Fred gets a refund on his microwave, the microwave is put back into stock and the stock count is incremented. Fred, the till operator and the stock controller are all stakeholders here.

In the case where we’re adding something to the logs, there’s a stakeholder who’s going to use those logs for something else. Having an awareness of that value can help us work out why we’re logging, and describe that outcome from the POV of the stakeholder who finds it valuable.

If the outcomes can be shipped independently and still be valuable, they can appear in separate scenarios. I’m pretty pragmatic about this, so I might put them in the same scenario to start with, then refactor them out later once the number of “stock control” scenarios means that it should probably have its own feature files.

If the outcomes can’t be shipped independently, which is usually the case with anything transactional, I like to see those outcomes appear together in at least one scenario, to make it obvious that they’re related. They don’t have to appear in every scenario. For instance, once we’ve written the scenario where the user doesn’t have funds so their account doesn’t get debited, we probably don’t have to mention the account again in any other cash withdrawal failure scenarios.

This perspective of multiple stakeholders is also related to the BDD concept of “Outside-In”, where all the behaviour we add to the system is done to provide a value to some stakeholder through some interface.

What about interactions with other users or with time?

Sometimes – very occasionally – we need more than one when to describe what’s happening, and the example of a login counter being incremented is a great one to use.

The value of a login counter is only that it disables the account after 3 attempts (for instance). It has no value in and of itself. It’s an implementation detail. If we made this into an outcome in a scenario, we’d be coupling ourselves to that implementation, which wouldn’t be great. So having two scenarios – one to describe how the login counter works and one to show why it’s valuable – doesn’t feel right since one of them isn’t describing valuable behaviour:

Given Clarence logged in successfully last time
When Clarence enters his password incorrectly
Then the login counter should be incremented.

Given Clarence's login counter was incremented twice
When Clarence enters his password incorrectly
Then his account should be disabled.

Yuk. Let’s not do that.

The only value in that counter is from the interaction of Clarence’s behaviour with Clarence’s future (or past) behaviour. So we could have something like:

Given Clarence logged in successfully last time
When he enters his password incorrectly
And enters his password incorrectly
And enters his password incorrectly
Then his account should be disabled.

Of course, that’s a bit of a mouthful, so we’d probably just say:

Given Clarence logged in successfully last time
When he enters his password incorrectly 3 times
Then his account should be disabled.

We can do that because it’s the same thing happening. Some interactions though involve different things happening (“time passing” is another one I frequently encounter).

Given Clare is editing trade 12345
When Stephen edits and saves that trade
And Clare tries to save that trade
Then she should be told that Stephen has already edited it.

In this case of course Clare’s interaction is different to Stephen’s, since her attempt to save fails.

Note the use of tries here to indicate failure; another example of how I use assumptions. If it doesn’t say tries we can assume that the event was successful. The alternative would be:

When Clare saves the trade successfully

Unless a successful outcome is somehow surprising and not the norm, this would get a bit repetitive, so I prefer to use nothing for the default and tries for failure. Having a difference between them is important from an automation perspective since it lets us do things like move the automated workflow to an error page instead of the confirmation page.

It also reads quite nicely. Which is pretty much why we’re trying to use these English language tools anyway.

Posted in bdd, stakeholders | 5 Comments

How to run a Futurespective

Futurespectives, like Retrospectives, look back at the past… from the future!

I find them very useful when there isn’t much to retrospect on: at the start of a project or initiative. I’ve run them for myself, for other individuals, and for groups of up to a hundred individuals, so it’s pretty flexible.

In a futurespective, we imagine that we’re in the future, and we look back to the past. Here’s the quick outline of what I do:

  • Set the scene and create a timeline
  • No explicit safety check (use common sense)
  • Step forward into the future
  • Look back at the past negatively (skip to positive if short on time)
  • State interrupt – break the mood!
  • Step forward into the future again
  • Look back at the past positively
  • Dot-vote
  • Create actions.

There’s some notes at the end too.

Set the scene

Imagine that the thing you’ve started has reached some kind of conclusion.

How long did that take? It could be the first project release, or the first time the team move onto something new, or the first time someone realizes that what they were trying to do has worked (or not).

I like to ask the people in the room, but if they don’t have experience, I’ll use mine or refer to other people’s. Futurespectives work well when the timeline is of the order of months or years (though I’ve done them with just days before!)

When we’ve decided what boundary of time we’re going to use, make post-its for any known or proposed events like release dates, deadlines, etc.. Tangential events which help people to imagine where they are in time are also useful, like the office Christmas party, or the rough date a team-member’s baby is due, or the start of school summer holidays.

The team can add any events they know of to this timeline.

No explicit safety check (use common sense)

Most of the time when I run this session, it’s because something highly uncertain is about to happen, often with people who aren’t used to working together. Asking whether people feel safe to share their opinions is less useful than encouraging them to be creative… particularly in the “negative” run-through!

Make sure you position the “negative” run-through as something of a ritual, so that people feel safe to make suggestions. I tell people that if the worst thing that happens is that a meteor hits the building, then that’s what happens.

Step forward into the future

I ask people to stand up and gather in a group at the start of the timeline, then walk with me as we progress through to the future. I talk about things that are happening as we move; any events that are occurring, the changes in the season, and events like Hallowe’en or that late blast of sunshine that we always get at the end of September; anything which reaches out to the imagination.

At the end of the timeline, we turn and look back.

Most of the times I’ve done this, there hasn’t really been enough room for everyone to traverse the whole timeline from start to finish; they get to shuffle along a little bit behind you while you lead the way. Remember to move past the end so that you give the group as much space as possible! The most important thing is that they aren’t standing where they started, and have moved to somewhere else.

This means that when they look back on the timeline, they will be able to correlate that movement more easily with the shift in time as well, helping them to imagine what happens next (or before).

Look back at the past negatively (skip to positive if short on time)

I like to make the first run-through the negative one, because then we end on a positive note. This one can also be quite funny.

I tell them, “Look back on the previous years / months since <date>. Wasn’t that just the most awful time you’ve ever had, ever? Everything went wrong.” Then I describe all the symptoms of it going wrong – people quitting, blaming each other, stealing the milk… whatever you can think of. I talk about my own role, too, with phrases like, “nobody is even speaking to that consultant you hired back in January!” or “that facilitator just didn’t help at all!”

I encourage people to be absolutely outrageous – in one organization Boris Johnson became the company Chairman; another large national company was reduced to less than 100 staff members because of the high turnover; quotes from “Office Space” and other parodies get scattered around liberally.

The outrageous ideas provide a container in which people can post dangerous ideas; things that might actually be a bit likely, but which would be taboo to suggest in a serious manner. We don’t ever discuss the negative things, so this is OK. Lots of elephants may emerge in the room. We’ll deal with them positively, later.

Ideas go onto post-its and those go up on the board. Ask your attendees to put any continuous events at the point at which they first noticed them happening.

I like to use pink post-its for bad things (and green or yellow for good things later), but I also put them below a particular line, leaving space between the negative ideas and the timeline above it for positive ideas (or you could have the timeline in the middle if you can make it visible enough).

As a guide for the space to leave, the positive ideas should be at or slightly above eye-level, and we normally use 1 or 2 feet (30 to 60 cm) of wall-space for each run-through, depending on how many people are involved and how long we can make the timeline in the space available.

State interrupt – break the mood!

I ask people something like, “Who’s a cat person here, and who’s a dog person?” or, “What’s your favourite film?” I often ask them why they think I asked that question, and they usually guess correctly that it’s to break the sad mood of the previous run.

Step forward into the future again

We repeat the previous walk-through, gathering at the beginning and walking back through to the future, with the same events (which is why the timeline should be of proposed or known events rather than imagined ones).

Look back at the past positively

I tell them, “Look back on the previous years / months since <date>. Wasn’t that just amazing? Look at all the awesome stuff that happened! All those risks we identified back in <this month>… none of them materialized. We managed to mitigate or minimize every single one! So many good things have happened! So many wonderful things! So what are they? What happened?”

Ask attendees to put the ideas onto post-its, and put them on the wall once more.

Dot-vote

De-dupe any of the positive events, moving them to the earlier dates if possible.

Ask the attendees to dot-vote on the events that are “most important, and least likely to happen without intervention”.

There are important events that will happen anyway, and unimportant events that people can work around. We want the events that are most risky; the things that really need to happen, but perhaps haven’t been started yet because people don’t know how.

These are often things that will only happen when people learn by trying them, so getting started is the important thing to do. This just gets people started.

Note that some of these may be the elephants in the room, but we’ve turned them into positive outcomes (see also Mike Burrows’ / Agendashift’s 15-minute FOTO if you want another excellent way to do this!)

Create actions

If anyone can make a difference to the events, or try something out which might help with them, they can volunteer for actions.

It’s highly likely that some of the events require sponsorship, authority or assistance from people outside the room. If you as a coach or consultant are in a position to help with those, you can go ahead and take the actions yourself.

Otherwise, ask if people know who to talk to. The action to take is then at least to have a conversation with that person.

Don’t create actions for people who aren’t in the room or don’t want to own them! That’s a really great way to waste post-it notes.

Notes

As long as some of the actions get taken up, and a bit of change happens, the futurespective was worth it. Change creates a new context, in which change has already been successful, which can make future changes easier and more likely to be attempted. In those situations the actions should be safe-to-fail probes. Simple conversations ought to be safe-to-fail (and if they weren’t, that’s useful information to have anyway).

It’s often the case that the red post-its pile up at the end of the timeline, while the green ones are clustered near the beginning; we need to act now to prevent problems later. If that happens, it’s worth drawing attention to it.

I sometimes get asked if we’re going to talk about the red ones. I explain that they’re only there to generate the green ones, but that if they want to, they can create a green one that’s an exact negative (“Boris Johnson does not become our chairman!”) and we can vote on that and talk about how to make sure it happens.

(In that positive timeline, he actually emigrated to Australia. I liked the imaginative creativity of that group very much.)

 

 

Posted in Uncategorized | 3 Comments

Probably not

When working in complexity, where the right thing to do emerges and we learn by actually trying things rather than by analysis, there’s a very human instinct that happens when we think of probes to try out. I see it all the time when I teach Cynefin, and I sometimes catch myself doing it (which means I fail to catch myself doing it a lot; welcome to bias).

I see people think of perfectly lovely, lightweight probes. “Let’s try using Slack.” “We could set up a visual board…” “Let’s try talking to the Ops team.” “It looks like a simple fix, and we can back it out easily if it fails.”

The urge that kicks in is then to take these lovely lightweight probes, which are perfectly safe-to-fail, and add stuff to them to give them a better chance of working.

“Slack? Fantastic; I’ll need the list of everyone to add to it, and I’ll set up these fifteen channels, and we’ll have a launch party in two weeks to encourage people to join…”

“A visual board? We should copy it into JIRA as well, and make a key of what colour post-its to use and here’s all the information that we need to put on them…”

“Our Ops team? Let me set up a meeting with our senior stakeholders and third-party suppliers so we can talk through what we need…”

“Release? You’ll have to work with the other teams and join the release schedule we’ve already set…”

The trouble is, these speculative investments of time, money or effort can mean that the probe is that much less safe-to-fail. Communicating a probe without being really clear that it’s just trying something out can result in communicating intent, leading others to create commitments around it, cementing it in place. The sunk-cost fallacy kicks in. “What do you mean, it’s not working? We spent two weeks on that…” The more people it reaches, the greater the impact and the need for success.

Having an awareness of this tendency has helped me to ramp it back. Instead of trying for something that will probably work, think about keeping it lightweight, so that if it doesn’t, it’s easy to fix or reverse or dampen in other ways. We’re aiming for things that might possibly work, or even plausibly work (I saw a figure from Ozzie Yüce that suggests only 1 in 3000 new ideas are actually successful). Keep it simple, small, or cheap, or short, or even hacked-into-place if that’s something you’re good at.

(Probes don’t have to be simple, small, cheap, or short, but I’ve found those are pretty good heuristics to work with.)

Resist the urge to double down by surrounding the probe with expensive scaffolding to prevent the failure. If it seems like it might not work, try to find ways instead to make it safe-to-fail. Those options that you make available for handling failure will work with other probes, too. (Automated rollback, for instance, makes all kinds of production releases safer, allowing all the teams involved to try things out more easily.)

And if you hear someone else’s ideas, please also resist the urge to tell them all the reasons you can think of that mean it’s going to fail, unless it really isn’t safe to do so (or your feedback has been explicitly invited).

In the complicated domain, things will work as predicted; in complexity, probably not so much. And that’s OK.

Posted in cynefin, real options | 1 Comment

Me too.

I don’t need to write a post about sexual harassment in the workplace. I already wrote one, 12 years ago.

Reading it back, I was struck by the paragraph I wrote about blurred lines.

I tried to remember what I was like, back then. I remember having chronically low self-esteem and a feeling of utter worthlessness. I valued every positive interaction that validated me in some way, even if it was borderline inappropriate.

I was in, then escaped, an abusive relationship at the time, but given I’m pretty bright and seem to be good at tech… why didn’t I feel like that was where my worth lay? Why was work also contributing, when it should have been uplifting me? I loved programming. I was demonstrably good at it. Why did I feel like playing into the expectations was the only way I could get ahead?

Oh, I remember.

Being told by a visiting professional in my A-level electronics group that I was “only there to hold the breadboard”. The lab partner who thought women should defer to men and couldn’t understand my behaviour. The students who tried to look up my skirt. The anonymous emails telling me how beautiful I was walking out of my lecture, describing my movements for some days. (Idiot got caught; it was sent from a university terminal.)

Then, at work.

The worst thing.

The guy who decided I was his wife, and referred to me as “wife” for about 6 months, even when our manager told him to stop (nothing else was done about it and I didn’t feel like I had any power). It still makes my skin crawl. I remember crying, a lot, thinking about the fact that I had to go to work again the next day. That was the worst thing.  Having someone think they own you. Being worried, every day, about what else was going to happen. Feeling sick. Watching other people watch it happen and knowing they saw me powerless and afraid and frustrated and angry. That remains, many years later, the worst thing.

Worse than being groped in the street in broad daylight in Bath. Worse than being followed home through Camden. Worse than the guy who decided to lift my skirt up in Slimelight to see what was underneath (and got thrown out by the bouncers). Worse than the guy who tried to put his hand in my top in Bristol (no bouncers needed; I chased him out myself).

It’s always worse when it’s work. We don’t have to go to clubs. We don’t have to go out late at night alone. We do have to work, and there’s no escape. It’s worse at work, but this one was worse than all the others.

Worse than the swimsuit calendar on the wall with the swimsuits made only of body-paint.

Worse than the high-level exec who stroked my hair in the pub as I passed.

Worse than watching 7 women be made redundant out of 10 redundancies for “performance reasons”, in a company with only 10% female staff. (I performed well enough, apparently.)

Worse than being asked if I only got the job because I was a woman.

Worse than being quizzed repeatedly about gender diversity issues, just because I’m a woman. (My favourite: “Liz, what’s difference is there between a team with women in and a team without them?” “How would I know? I’ve never been on a team without a woman in.” “Really? How come?” Duh.)

Worse than having to tell someone with a topless woman on his t-shirt – at work – that it was making some of us feel uncomfortable.

Worse than being asked why I was out at a conference, and shouldn’t I be home raising the kids I choose not to have, because how else could any man find any value in me?

Worse than the tweet that said I only won a prize because someone was “stung by gender diversity issues and trying to redress the balance”.

Worse than having someone tell the crowd at the bar that “I’d better cover up my pint, otherwise Liz might want to drop rohypnol in it.” (This comment was freakishly out of the blue, I promise. We had no history of intimacy. We had no CoC either. He doubled-down when I told him it wasn’t funny. I have no idea why his head went there. It scares me more than a little. I try to avoid speaking to him these days.)

Worse than a long-term mentor telling me that I should “have more empathy” for that guy.

Worse than having someone touch my ass at the conference bar (kudos to the LASCOT conference organizers for the sensitive handling of that one; CoCs rock).

Worse than all the other things.

It was a long time ago, that worst thing.

I keep thinking that maybe I’m lucky it wasn’t worse.

I keep thinking that maybe one day I’ll be old enough that it will stop happening to me.

I keep thinking that maybe the world will be better, and it will stop happening to anyone.

12 years later, it hasn’t stopped.

Maybe I need to write a post after all.

Posted in life | 15 Comments

On Real Options and Speculative Investments

If you’ve read the awesome graphic novel, “Commitment”, you’ll know the rules of Real Options already:

  • Options have value
  • Options expire
  • Never commit early unless you know why.

There’s an additional rule which is sometimes added to this:

  • Options have more value as uncertainty rises.

…and software development is full of uncertainty.

We do want to make commitments; also investments, which are the subject of this blog. Failure to act is itself a decision, and at some point options do expire. As David J. Anderson says, “If you leave it long enough, eventually everything becomes an expedite.” The problem comes when the commitments are premature, and the investments speculative. So this post is about minimizing speculative investments, and avoiding premature commitments altogether.

An option is the right, but not the obligation, to do something or get something.

Chris Matts took the term “Real Options” from financial options, for which we can easily assign value; the right to buy cocoa beans at a certain price right before Christmas so that your chocolate factory can meet its own commitments to provide chocolate Santas to its customers, for instance. If cocoa beans are cheaper than the option price, we don’t need to use the option. If they’re more expensive, we exercise the option and we get our beans affordably.

In real life, options are harder to value. They’re just choices. However, they have value, and we as human beings tend to exercise our options way before we need to. We have an innate dislike of uncertainty. Our confirmation bias serves to make us think we have certainty and understand the patterns we see, even when we don’t. That’s great for helping us move forward in an uncertain world… but if we could move forward in a way that kept two directions open for us, cheaply, why wouldn’t we?

The other problem I’ve encountered is that we don’t actually commit a lot of the time. Instead, we make heavy, and speculative, investments.

A speculative investment is risky.

In finance, a speculative investment is one which may entail a significant degree of loss, and which by its nature is uncertain. I’m talking about real-life investments, which might be of time or effort or willpower or social capital. The term “speculative” also means “based on conjecture, rather than knowledge.” Like premature commitments, a speculative investment is one made in an absence of good information.

So what’s the difference between a commitment and an investment?

Commitments are discrete; investments are continuous.

Let’s say you’re skiing, and the lift is broken. You plod up the mountain with your skiis, investing in the ride down. At some point you realise the slope is a bit steeper than you thought, and not a good match for your ability. You decide you’ve invested enough, and put your skiis on, and off you go. Only the effort you’ve spent is committed; you haven’t made any future commitments. The decision is a continuous one, and can be changed at any point, dampening future consequences. If it’s a bit too steep for you you might feel a bit uncomfortable and you’ve still got a chance of crashing, but at least you were able to stop when you did.

A commitment is jumping out of a plane. If your parachute doesn’t work, you can’t change your mind half-way down and decide you’ve had enough. The future consequences are unavoidable.

I think of investments like a slope of expired options against time, with the steeper slopes being heavier investments, and commitments being a vertical line. Sometimes investments can turn into vertical lines, like the V1 point at which a pilot is pretty much committed to taking off from the runway and can’t abort. Sometimes they can be unwound, but the unwinding can be painful, like plodding all the way back down the mountainside.

Investments in software development prove really interesting, particularly because of two human biases: confirmation bias, and the sunk-cost fallacy.

Together, they lead us to commit to the direction set by speculative investments, thinking that we have certainty and good information when we don’t; and to build on the investments we’ve already made, even if we do have information that they’re wrong. Sometimes the commitment is just a mental block. Sometimes we communicate it to others, creating reputational or contractual commitments. Sometimes we tie other decisions to the investment, making it a far heavier investment than it was before, until it’s practically a vertical line anyway.

Here are some common examples of speculative investments that I see in software development, and some ways of improving your process by making that investment smaller and lighter and less likely to invite commitment.

Research, analysis and design done a long time ahead of the actual development. (Yes, two weeks is a long time.) Prototype as soon as you can, especially if the solution is technically complex. Use the prototype for guerrilla testing. Keep your options open by having several different designs (concurrent set-based engineering, or in Cynefin-speak, parallel probes). Don’t worry about bits of the design which are easy to change; fonts and colours and spacing and even layout can be sorted out later. Bonus points to designers who can sit with the devs and help them tweak the final bits… especially if it means you learn a bit of code yourselves.

Backlogs that require grooming. This is another sign of speculative investment in the form of analysis. I find planning at the capability level is a good level of granularity at which to stop. Put them on cards or post-its and stick them on a wall somewhere. A big one-year trading project had about 37 cards. The projects I work on now are typically a few months long and have ten cards or so. Let the team break them down as they come to them. Focus on the riskiest ones that the team know least about, too, so that you can make discoveries and get the information for good decisions early. And minimize the work you’re looking at! If you don’t need it, don’t put it on the wall until you’ve done the stuff you need (and often, discovered what that really is). Everything else is an option, and options have value.

Yearly budgeting cycles. Most organizations do have a process for changing direction mid-year, but it’s painful. The cost of unwinding heavy investments often is. Bjarte Bogsness’s work on Beyond Budgeting is excellent for separating the different concerns of budgets like resource allocation and motivation and prioritisation, providing more flexibility, as well as being beautifully alliterative. Budgeting for half a year or quarterly lets you change direction more frequently. Concepts like BHAGs, True North and the One Metric That Matters (OMTM) can help departments to align, letting them make decisions locally, enabling greater trust and more autonomy for spending the money you’re giving them.

Leaving testing to the end. Doing this at the end of a project is going to hurt you badly, but even leaving testing to the end of a sprint means you’ve got two weeks of speculative investment of code. Devs, if you’ve got something working on your machine, and your tester is co-located, go and get them so they can see it. Chances are you’ve forgotten something. (Chances are good you’ll remember it as you’re walking across the room.)

Big releases without the possibility of rolling back… or without the information that tells you that you need to. Actually, this is a commitment rather than an investment, since you’ve got no choice but to enjoy the freefall. I heard of one company that had to cease online trading for months afterwards… or there’s Knight Capitol Group, which, well, it doesn’t exist any more. Don’t do big-bang releases with no rollback, unless you’re really sure that you’ve eliminated uncertainty or opened some options for yourselves through other means. (If this is the norm for you, you probably don’t have those techniques either. Start learning, because your competitors do.)

It’s all about investments and commitments.

These are just a few examples of speculative investments that I see in software and the wider organization, from code to corporate strategy. We’ll always have some level of speculative investment, because we need to move forwards and uncertainty always exists, but it doesn’t need to be heavy. Minimizing speculative investment is a principle which scales.

I’ve realised that just about every aspect of my job as a Lean / Agile coach and consultant is about minimizing these speculative investments and avoiding premature commitments; encouraging people to keep options open by creating safety (organizational, technological and psychological), minimizing queues and feedback loops and embracing the riskiest and most uncertain work so that information for making better decisions arrives earlier, helping people limit the work in progress with that “stop starting, start finishing” mantra so that the investments already in flight pay out or give us feedback earlier, clarifying direction to allow for swift and autonomous changing of decisions, and helping people communicate and visualize with greater transparency.

Everything decision we make, we do with the information we have. We often make the wrong decisions, and more so when we don’t have good information. Unless there’s something urgent going on (because chaos is often what happens when you make premature commitments), we want our investments in uncertainty to be probes; a Cynefin term which means trying something out that’s safe-to-fail, with feedback on whether it’s succeeding or failing and mechanisms for amplifying it or dampening it accordingly.

With investments, being wrong less doesn’t have to mean being right. It can mean being wrong with less money, in smaller contexts, for less time, with less stuff and fewer people.

That’s how we keep our most important option open: the option to do something else instead.

Posted in cynefin, real options | 1 Comment