Re: how many bugs do you find and correct during TDD?

From: Ilja Preuß (it_at_iljapreuss.de)
Date: 01/02/05


Date: Sun, 2 Jan 2005 11:07:37 +0100

Tammy wrote:
> Ilja Preuß wrote:
>> Example: Does the for loop need to end at i<n or i<=n? Without the
>> tests, I'd think hard until I knew, possibly even execute the
>> algorithm manually on paper to be sure.
>
> Wow, i wonder if people take not knowing to this level?
> It seems to me you aren't able to keep those
> items in your mind at the same time and reason through the
> scenario correctly. Is that true? Or is it not worth the
> effort in your mind?

It's simply not worth the effort to me. I'd need to write and execute the
test anyway. Letting that test tell me is more effective to me than
reasoning about it.

Perhaps it's just me, but one-off index errors aren't that seldom to me,
even if I take my time to reason about it. The only way for me to know that
I got it right is to run the test.

> Where do you stop? Do you just put in any variable names
> and then correct them as it doesn't work?

No.

> Do you use any
> looping construct and then correct it until it works?

I don't understand what you mean.

> Do you use any comparison and then correct it until it works?

No.

> I really don't see the need to execute something on paper
> when you can execute it in your mind much faster with
> equal precision.

As I said, I find that I often get this special case wrong, no matter how
much I think about it.

>> With TDD, I just choose the one that looks more persuasive
>> and let the tests tell me wether it was the right one.
>
> How could you write a correct test if you can't reason what
> the post condition should be?

Let's take an algorithm that replaces two '$' by a single one:

assertEquals("a$b$c", foo("a$$b$$c"));

There possibly is a loop somewhere in foo. If there is, and it has a one-off
error, one of the following test cases could fail:

assertEquals("a$$c", foo("a$$$$c"));
assertEquals("$b", foo("$$b"));
assertEquals("a$", foo("a$$"));
assertEquals("", foo(""));

Writing these testcases, to me, is often much easier than reasoning about
wether the algorithm would make them pass or fail.

>> Would that count as finding a bug, by your definition?
>
> No. You don't expect it to work.

Yes, but I also don't necessarily expect it not to work... ;)

>> Well, it's probably more important to the customer, at least... ;)
>
> It is important. It's not the only thing that is important.

Do you think it is/should be important *to the customer* how many bugs we
find in the TDD cycle?

Cheers, Ilja



Relevant Pages

  • =?iso-8859-1?q?Re:_What_does_G=F6dels_Incompleteness_mean_for_the_Working_Mathematician=3F?=
    ... > Axiomatic languages do not lead to contradiction unless we have reason ... > There is no reason to believe that either is the case in Peano ... > algorithm computes an arithmetical relation R, ... theorems, theorems about dimension). ...
    (sci.math)
  • Re: Help to make a better shortest route program
    ... between two cities. ... long to execute. ... generally look at your algorithm and make it better. ... Shortest: integer; ...
    (comp.lang.pascal.misc)
  • Re: "PenTest" a container file
    ... I consider the fact they are using a private encryption type as a giant red flag for the system. ... There is no reason to use a proprietary system when there are many free algorithms that have been thoroughly examined by the crypto community. ... If I used a slight modification of DES the odds of cracking it in a few weeks without knowledge of the algorithm is pretty slim. ... If you just have the container file and not the app and any associated files, I don't think there is much chance of cracking it, unless they used something horrible like ROT13. ...
    (Pen-Test)
  • Re: Just curiosity about some constructs
    ... > I have still curiosity about the reason of some C constructs/keywords... ... Was at that time a compiler ... This is about the switch statement. ... A whilewill execute the statement after the ...
    (comp.lang.c)
  • Re: Inlavid Operation ereror when refresh table link
    ... I disagree with your first point, where you are saying the Append ... while the rest of the program continues to execute. ... The reason is that for performance reasons Access does not refresh the ... looking for some reason for a Tabledef to be created, ...
    (comp.databases.ms-access)