Tuesday 27 September 2011

I Could Murder a Cuppa

During our annual meeting, we were set a relatively simple challenge, we divided into equal teams, and we were all set a simple process to document and present to the group. This sounded quite simple but it was very interesting to see different peoples' takes on the requirement.

Here is the exercise I'll be covering in this Blog. Making a cup of Tea:

  1. Fetch the kettle
  2. Open the lid on the kettle
  3. Turn on the cold tap
  4. Fill up the kettle to the max line
  5. Turn off the cold tap
  6. Put the lid back on the kettle
  7. Put the kettle back on it's base
  8. Plug the kettle in to the electrical socket
  9. Turn the kettle on at the electrical socket
  10. Switch the kettle on
  11. Open the cupboard door
  12. Get a mug
  13. Put the mug on the worktop
  14. Go back to the cupboard and get a tea bag
  15. Put the tea bag in the mug
  16. Wait for the kettle to finish boiling
  17. Pick up the kettle
  18. Pour water into the mug to the desired level
  19. Leave for 3 minutes
  20. Go to the drawer and get a spoon
  21. Stir the tea and remove the teabag
  22. Open the bin
  23. Put the used teabag in the bin
  24. Close the bin
  25. Put the spoon down next to the mug
  26. Go to the fridge and open it
  27. Get the milk out
  28. Open the milk
  29. Add some milk to the mug with tea in it
  30. Close the milk
  31. Put the milk back in the fridge
  32. Close the fridge
  33. Pick up the spoon from next to the mug
  34. Use the spoon to stir the tea
  35. Drink
Now this simple 35 point process all comes from the simple requirement, make a cup of tea!

Now this is quitovee straightforward, any first year university student could have a reasonable stab at this with a high success rate but let's take it a step further. Let's say that you were meeting a customer for a discovery workshop and they passed you a requirement to make a cup of tea. You decompose it down into a series of managable tasks and race to the implementing of it but I've made a common and fatal mistake in the process list above. It's blindling obvious but has caused no end of problems in projects since the dawn of IT. I've potentially made some fatal assumptions: Do we have a kettle? Do we have Teabags? Does the customer want their tea without Sugar? The list goes on and on...

The point of this is that don't be in a rush to implement, think about the requirements,
  • List all your assumptions, get them verified by the customer. 
  • Think about your happy path and get this in place first
  • Think about all your exception flows and hang them off the happy path flow
  • Thnk about how you are going to test it?
    • What are the pre-conditions?
    • What are the post-conditions?
This is just as valid in Agile as it ever was with Waterfall approaches, admittedly in Agile you may proceed without knowing the full requirement but you should still attempt to flag the unknowns to be bottomed out later. Making sure that your requirements are fully thought out is the only sure fire way I've seen to prevent the 'ball of mud' coding pattern from becoming the predominent pattern on an implementation. An hour spent upfront clearing up your requirement and thinking your way through a problem will invariably prevent a throwing code at problems to make them go away.

This may be a very simplistic way of demostrating my point but it's a simple thing that if done incorrectly can have serious consequences? We could potentially have gotten to step 27 before we realised that we hadn't actually got any milk!



Finally, I suppose I should give the answer to my previous blog, this is quite simple once you start to dry run the principles in your head and you have ever got a divide by zero exception :). The answer is simply that the equations don't work as if X == Y then X-Y will always equal 0... Therefore, to divide by X - Y is to divide by 0 which cannot be done

1 comment:

  1. Great Post Chris, and lets face it, if you make mistakes during the requirements stage, you run the risk of ending up with a Chocolate Tea Pot at the end of the project !

    ReplyDelete