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.