Friday, October 10, 2008

TDD is vague

I was asked recently about TDD:

What is it exactly? What's the difference between it and Test First Programming?

The questions were raised by one of my colleagues in a Test related activity we had. (Simple curiosity about a handy acronym heard somewhere some time ago and if applicable to what we were doing)

My quick answer: "Test Driven Development is not only about writing your test first! It implies you also see the system as a tester/user. In TDD you ask yourself questions like: What can go wrong? What other scenarios must be considered? Guidance from a preventive QA team would be welcomed in this process... "

Context : we were developing(peering) a new feature - new GUI and related functionality in a TDD manner, writing quickly the functional test (called by us "GUI test") before, and trying to keep the green bar afterward.

After some reflection I realized that TDD is a vague acronym. Why? Because "Development" is also vague.

Development examples :
  • explore a simple idea: It might be possible to create this new method that will save us from this amount of code duplication.
  • explore a new technology, use it in the application: Can we use hibernate? Yes. We need to use these annotations. Data is persisted.
  • design a number of classes with complex behavior: We have performance related problems - we need to cache previously computed results. We must be able to invalidate the cache.
  • design a number of classes with complex structure: For the given primary inputs, we must be able to compute and save intermediate results.
  • build business structure: Make this "Foo" editable, you did the same for "Bar"
  • build business behavior: We have to create these Business rules.
So TDD could mean:
  • Test Driven Exploring (driven by learning oriented tests)
  • Test Driven Design (driven by design oriented tests)
  • Test Driven Structure Implementation (driven by GUI oriented tests)
  • Test Driven Behavior Implementation (driven by acceptance criteria oriented tests) - thank god we already have a name for this : BDD
  • ...
So, answering TDD is not easy, it implies Test First, it implies small steps, various external preoccupations on a case by case basis: what may break my design, what other GUI interactions may work wrong, when can we say acceptance criteria passed, ..

It's been a while since I wrote this post. Reached a very nice post about another TDD meaning:
  • Test Driven Refactoring (driven by refactoring oriented tests)
Reached another nice post regarding TDD & Test First: TDD does not mean Test First. "TDD does lead to better code - test first does not." Really enjoyed the formulation!

No comments: