Testing is necessary, but it is not enough

A couple of weeks ago, the Scrum Breakfast in Bern featured a presentation on test-first programming. The presentation was well attended by some 40 people. I was impressed by this number, but what fascinated me was the answer of the audience when the author asked who is or has been employing test-first programming: I was the only one raising my hand. Maybe people were shy. In any case, it is great that the software industry is finally ready to pay attention.

An intense discussion came out of it. Interesting enough, the debated issues were not about challenging test-first programming. Instead, they were focused on the relation between testing and architecture.

The discussion spawned from the claim that test-driven development helps emerge the design. The speaker gave a nice short demo of starting from scratch and emerging the design of a simple application. It worked quite well, and it showed how design decisions can be identified by following the simple TDD algorithm.

However, the concern was still related to what happens with the coherence of the architecture. Indeed, testing does help crystalize the functional responsibilities of the components, but you can still very well get into a state of structural mess.

Let's take a closer look at what TDD says. Beside the classic writing tests, implementing the associated code, and running the tests, there is one step that is typically taken for granted even by seasoned agile developers:

Tdd.png

After implementing the functionality, you should clean the code up. This is where refactoring comes into play as a means to change the structure without affecting the functionality. But, before applying a refactoring, you should still know what needs to be cleaned up.

In general, it is mess you want to clean up. And what is mess? Mess is anything that breaks order. And how do you know what breaks order? You check what happens in reality and compare it with the desired order.

In the case of software systems, the order of the structure of the system is defined by the desired architecture. Testing is necessary to control functionality, but it is not enough to ensure the desired quality of the emerging architecture. You also need to check the structure. And as the system is too large, you need to automate the check. Just like you do with tests.

Posted by Tudor Girba at 25 August 2011, 8:24 am with tags assessment, process link
|