📜 ⬆️ ⬇️

TDD does not work


TDD is not working.


True? Strange. I've always worked well.


But a new study suggests otherwise.


New research?


Yes, an in-depth study that replicated the steps of another study conducted several years ago. Both showed that TDD is not working. A new study took place in several places, using blind analysis. It looks convincing.


Do the authors find it convincing?


The authors recommend conducting new research. But they are most likely just being shy. The results are pretty convincing.


What are the results?


Research shows that statements about TDD are false. TDD does not increase development speed. Does not reduce the number of defects. Does not help writing better code.


Very strange. It seems to me that TDD increases my speed, improves my code and accuracy. I know other people who will agree with me. It is surprising to me that the study came to a different conclusion.


Well, nonetheless. DHH was right. TDD is Dead .


Hmm Ok, so what exactly did the study authors do? How did they come to that conclusion?


I dont know. I only know what research was.


How did you find out about this research?


I read about it in a blog . In the end, the author said that it made him rethink TDD. He believed that TDD worked.


Well, let's look at this research. Hmm ... Yes, it says here that they compared TDD with TLDs.


What is a TLD?


Test LAST development. This is when you write unit tests after writing code.


Here you go! Research has shown that it is better to write tests at the very end!


Hmm No, it seems that this is not what the study showed. In fact, it showed that there is no significant difference.


Oh well. That is, if I write code, and then write tests, then this is no worse than TDD.


Well, not quite. In any case, this is not what the study says. In its course, TLD supporters were asked to work in "small chunks."


In small pieces?


Yes. TLD supporters wrote a bit of production code, and then some tests.


Yeah, got it. That is, they wrote a production code of 10 minutes, and then 10 minutes they wrote tests, or something like that.


Well, maybe. But, look, it says that all participants had TDD training. And then some of them were asked to make the TLD in small pieces.


Yeah. OK. Well, my statement is still true. They wrote a production code, then they wrote unit tests. And it did not affect anything.


Let me ask you a question: how would you write unit tests after production code, but in small pieces.


I would write a little production code - enough to pass a couple of tests, and then I would write these tests.


How would you understand how much code you need to meet a couple of tests?


I would introduce a couple of tests, and then write a code that satisfies them. Then I would write tests.


You have skills in TDD; that kind of thinking would be obvious to you, right?


Mm ... Hmm ... I think I understand what you mean. TLD's simply did TDD in their head, and then they implemented everything in reverse order.


Right. To work in small pieces, they needed to submit tests in advance. So that you can write testable production code.


Maybe this study did not investigate what was intended.


It seems to me that they were trying to investigate the procedure for writing tests, and not the TDD process itself. In an attempt to reduce the number of variables, they got rid of them all. They forced TLD participants to use the TDD process in short cycles. And it made the participants work on the code and think about the tests in advance.


OK. May be. But still these TLD's wrote tests at the end . Tests showed at least that it is not necessary to write tests at first - at least if the work goes through short cycles.


Of course. The effectiveness of TDD depends on the size of the cycle, and to a lesser extent on the priority of the tests. We write tests in advance, because it pushes to reduce the length of the cycles.


That is, this study showed that people working in short cycles may not worry about writing tests in advance. The main thing is to continue working in short cycles.


Looks like a fair conclusion. But look here. Participants worked on The Bowling Game . This is a very small task. They said it took them only three hours to do everything about everything.


It is important?


Of course. The use of writing tests in advance is a discipline . Writing tests in advance does not allow the cycle to grow. Retains a high degree of coverage over long periods of time.


Yes, but if you have enough discipline to keep the cycles short, then, according to the study, it doesn't matter when writing tests.


Yes, but it's more if. The study shows that if you take a group of people with training in TDD and tell them to do everything as well, including keeping the development cycles, and only changing the order of writing tests, then it’s impossible to notice any difference in three hours of programming.


Yeah. Yeah. The study shows exactly that.


So in reality, research made a difference without difference.


Well ... Hehe, they found no difference, so perhaps yes.


That is, the study did not show that TDD does not work, right?


No, it probably did not show.


What did it show?


I think it showed that it is impossible to interpret the findings of research without reading the research.


')

Source: https://habr.com/ru/post/314994/


All Articles