Thoughtless Development
Test-Driven Development has gone from being a new idea, considered slightly crazy, to a serious development style used by many professional developers in their everyday life. However, it is a style of development which requires much discipline, or you will not realize it’s potential. In fact, you might end up doing more harm than good.
Traditional vs Test-Driven
The traditional way of developing (if there is such a thing) typically follows this pattern.
- Implement a feature.
- Test follows from implementation.
Whereas Test-Driven Development reverses that order.
- Test a (missing) feature.
- Implementation follows from test.
The idea here is that if we design and write the test before concerning ourselves with a particular implementation, we are more open-minded and the resulting feature will be designed as we want to use it rather than how it’s easiest to implement.
Thoughtless Development
Some people (myself included, in an earlier life), tend to get this idea slightly wrong. They end up with, what I call, Thoughtless Development. When converting from traditional development to TDD, they know the implementation is supposed to go last and follow from the tests.
For some reason though, they keep the “test follows from implementation” part. But as the test is supposed to be written first, there is no longer anything it can follow from. To make it even better, it is also supposed to be as simple as possible, which is easily interpreted as easy to do as possible. The flow typically ends up something like this.
- Test follows from (vague expectations of) implementation.
- Implementation follows from test.
Do I need to add that they typically end up with a heap of junk? That’s because there is no room for thought in this process. All the thinking and care that should go into designing tests is forgotten.
As I’ve written about earlier, some people tend to use TDD as an excuse for doing no design at all. Either purposefully or by accident. This is ironic, as TDD is really all about design! So let us all make sure that we are doing Test-Driven Development, and not Thoughtless Development.