May 22, 2007

...Learn TDD with Codemanship

How Buggy Is My Code?

Right now, my mind is on test coverage. Inevitably, when someone presents me with a body of code and asks me: "how buggy is it?", my immediate thought is how tested is it?

It's not an exact science, of course. It's possible to achieve very high quality code without performing manual or automated tests - although you could argue that inspections, peer reviews, formal proofs and wotnot, are all kinds of testing, and they each have similar concepts of test coverage.

Actually, I look at three variables to help me estimate how good a body of code is likely to be:

* Complexity - how much is there that could go wrong?
* Capability - from looking at the code itself (the craftsmanship of it), how good were the developers that wrote it?
* Test Coverage - how much of the code and its logic has been tested?

Let's say, for example, that I look at your code. In your code I find many methods that contain dozens of nested IFs and FORs. And there are no unit tests. And the code has a distinctly procedural, 2-tier client/server flavour to the design, with most of the logic split between UI event handlers and SQL stored procedures.

Using my little matrix, I see that your code has HIGH complexity, and was written by developers with apparantly quite LOW capability, with apparantly VERY LOW test coverage.

And you ask me "so, how good it is it?" My answer would probably be "if it were my horse, I'd shoot it myself".

Sometimes it's the most humane option...
Posted 14 years, 1 month ago on May 22, 2007