Sunday, March 13, 2011

Intense TDD Focus Not So Healthy?

I believe in the value a TDD/BDD approach yields. However, I have seen great software produced with no unit tests at all and really poor code produced with lots of tests.

TDD is one perspective of many that affect the outcome of the quality of your software, so for some time now, I have been a little bewildered by the somewhat over-the-top hype surrounding TDD.

Now I have finally figured out what it is that bugs me so much about the current trend of TDD/BDD hysteria.

During the design process, I think about the various alternatives - at varying levels of abstraction - weigh up their pros and cons, discuss with the team and consider the impact on the overall architecure.

Sometimes, working with pro-TDD people, I find that I am under pressure to make key design decisions as quick as a keystroke, because I cannot have a failing test for more than a few minutes - right? I am given very little think time. Which is what I feel great design is all about - thinking!

TDD provides a great perspective on micro level design, and provides us with a more solid API with the focus on test/specification as a client of the code under test. Even so, I still think there is a tendency to proceed a little too quickly at the cost of considering the alternatives, but sometimes at this level of abstraction, the building blocks are smaller and so there is less to keep in the brain at once.

At the macro level though, we often want consider the various responsibilities, whether things fit neatly within the existing architectural and design constraints and mechanisms and put more of a focus on the non-functionals as well.

Which is more important? This has been the focus of argument between the design/architecture and programmer/developer communities for some time. My feeling is that they are equally important. What's more, there is no artificial dividing line between architecure and code, there is a single continuum and great developers and architects constantly think and adapt along the continuum. There is effectively no difference between great developers and great software architects. Others remain stuck, constrained at the specific levels of abstraction about which they care.


Paul Beckford said...

Hi Andrew,

I like to think of a computer as a blank canvas, and the gigabytes of random access memory as an awaiting medium. Making an impression on that medium that is purposeful, expressive, long lived and aesthetically pleasing is an act of artistic creation.

Just like art there is a subject, a domain which the artis wants to capture. Then there are the tools, the ink and the quiver. Finally there is the medium itself, the vocabulary and the grammer of the chosen means of expression.

One way to think of a programmer is as a novelist. Great novels have both micro and macro structure. Both of these structures are in tune with each other, and there is a consistency of style as you move from the narrative at one level of abstraction to another.

Just like a good novelist needs to know how to produce a compelling plot, alongside an adept sentence, so does a good programmer need to know how to arrive at a compelling architecture alongside an adept unit of code.

Being able to rapidly traverse this ladder of abstraction is a skill in itself. For the best developers this ability becomes intuitive.

What you are describing here is a lack of skill. Knowing when to focus on what, born from insufficient mentorship, and deliberate practice. In my mind there are actually three aspects to it. Modelling the domain, modelling the macro solution and modelling the micro solution. A good developer does all three at the same time. You can't afford to ignore any of these, which is why Ken Beck characterised programming as:

* Listening
* Designing
* Testing
* Coding

This is programming. This is software development. All other labels are just noise :)

Take care,


indexurl said...

Thanks for sharing such useful information. The information provided is very very niche and this information is not available so easily. Therefore I thank the writer for the useful input.

seo services India