Tuesday, March 13, 2007

TDD Evangelizing Experiences

I was discussing about usefulness of developer testing and TDD stuff with one of my friend, Kapil. I told him "you should avoid debugging at all costs" - debugging is painfully mundane and costly activity, "one of the way of avoiding it is; to write automated unit tests", he said, "I avoid it by debugging differently..".

I asked how and what different debugging techniques, and he gave an example of manual technique to avoid seeing what's going in code ("If a file is not found, I'll try renaming or something like that"). I said, "this is no debugging, its kind of troubleshooting to avoid debugging". He would not agree to it.., then I told him why not write an intelligent program which will do the same thing programmatically ?(well, its kinda behavioral testing), then? well then he was interested in listening... and was ready for few pills of TDD :).

With few examples, It was easy to explain him how TDD can change the way you think about developing software, he already knows it a bit, tries to minimize it through other manual hacks (this is partially because PHP has smattering good debuggers and he works on PHP based server apps).

I told him "debugging happens to be one of those trivial activities which doesn't differentiate you from others" (no big deal, everyone can do it, right?); You need to consider audience attitude for a successful systematic evangelizing :).

TDD, in its real sense-the test first, is one thing that I still find difficult to explain to people; It requires you to give it a shot without unveiling providential "Zen" behind it, somethings you should just try without resisting and put in practice if you find it effective.

Once, I explained TDD to my trainee team at C-SAM, I explained it by example, told them what happens when you don't have tests, made them feel the pain of debugging; then write tests and show what great peace of mind this automatic testing gives.

To sum the experiences on evangelizing TDD:
  • To a good programmer explain the benefits of writing intellectual tests rather than idiot debugging every time.
  • To a novice, give a real example; mock a bad situation and exhibit how to tackle it with TDD.
  • To an amateur, explain how tests are better than manual troubleshooting.
Kill Debugging, Write tests.

I hope this experiences will find some use and benefits in development.

5 comments:

KetanPadegaonkar said...

Indeed!

I've observed that writing tests is really cool.

More than the coolness factor, I've realized that they get rid of repetitive bugs that crop in. Also tests ensure that I'm able to test my software in a few seconds to see if the changes I've made have broken anything.

As far as debugging is concerned; hehe.. what's that, I remember seeing a debugging perspective somewhere in Eclipse. Tests, and test coverage ensure that methods are as small as possible, which further ensures testability, readability and reduce the chances of bugs cropping up.

Nirav said...

I'm happy that you found importance of tests so quickly, it will go long a way in developing better software....

Devang said...

Can you give some real example to get an idea of real need of TDD.

Nirav said...

I've answered it here
http://niravthaker.blogspot.com/2007/03/six-reasons-why-tdd-is-necessary.html

Cedric said...

More testing doesn't mean less debugging.

Read this: http://beust.com/weblog/archives/000437.html