Posts Tagged ‘TDD

29
Dec
07

Book: TDD by Example

Or more formally known as Beck’s TDD, is a very lucid book, in the sense that I’ve read it in one swell foop. It took me from morning, through eye-drying moments, to late evening, but I just couldn’t stop reading it.

This book is mostly fun, and you get the side-values of learning a lot of important lessons in TDD and development in general.

Just as a brain teaser, Beck philosophically speculates that flexibility only comes where you need change, this is his “triangulation” mantra.

[spoiler alert]

In short, it means that to implement a function that adds two numbers, we write a test:

Assert(4, add(2,2))

And we implement it as:

function add(a b): return 4

How well do we know the add function? from kinder garden we also know that 3+4 = 7 so we re-implement:

Assert(4, add(2,2))

Assert(7, add(3,4))

And we “triangulate” the code:

function add(a b): return a+b

We applied the minimal possible change to the code that makes the tests pass which means it is now as simple as it gets = elegant.

We took things in baby steps which means we have less margin for error.

We left little for speculation.

This is test-driven development.

Ofcourse, this book also gets my rare 10/10.