Composing Features

March 19, 2009

#Composing Features

Writing good features is an art-form, a very new art-form that people are just beggining to explore. Of course people have been specifying how things should work throughout history, and people have been trying to specify what software should do (with varying degrees of failure!) since software has been written.

You can compare writing features to a new school of art e.g. pontillism. Pontillism built itself on the existing foundations of painting and art - in particular colour theory

  • and applied these using a new technique to create something a little different. In our new school of features we produce something a little different (a plain text executable) with a new tool (Cucumber) and the application of old and new techniques. To do this well we have to learn what works and what doesn’t.

#Asking Questions

When we write a feature we need to ask lots of questions. A feature is an exploration of something we want to do. Starting a feature is focused on two things, loosely describing the feature and asking the most important question.

  • Why do we want to do this?

The first temptation when writing features is to skip this question! After all we know we need the feature, otherwise we wouldn’t be writing it in the first place. And we want to get on with things! What’s the point in wasting time on this question?

Well your about to commit a substantial amount of your time writing this feature and a substantial amount of other peoples time in implementing this feature. If it takes you 20 minutes to answer this question properly and you discard one in fifty of your potential features you will still have saved loads of time and effort.

To help you answer this question you can consider the following questions

  • Whats the point?
  • Can it wait?
  • Is there something more important we need to do first?

#Writing Scenarios

Once we get to the stage of writing scenarios, we should be fairly confident that we are not going to be wasting our time writing the scenarios. In addition to specifying what should be done, writing scenarios help us to discover things about our feature. As we write our feature we should be open to the following ideas

  • We need to do something else first!
  • We don’t need to do this now!
  • This is pointless!
  • We don’t need this!

Hopefully the point is made now!

#Writing Scenarios (the details)

As you write a scenario its a good idea to ask a few more questions.

  • What am I assuming?
  • Where does this come from?
  • Is this a compound statement?
  • Do I know what this really means? And even if I do can anyone else?
  • Who can do this?
  • Who should not be allowed to do this?
  • Is this name ambiguous, clumsy, accurate, intuitive?

To write scenarios efficiently we need to develop the skills to ask the write questions at the right time. A warning though - not asking questions, guarantees you will write rubbish, be innefficient, waste other peoples and never develop the skills to write scenarios quickly. Remember this is an art form you have to really work at it to get good.