Live data from Hacker News

Giving Up on TDD

blog.cleancoder.com

81–90 of 112 posts

Re: Giving Up on TDD

#81
post #2

> but he said he was just using it for some home projects I think here lies the biggest problem. For small/hackish projects you barely get any benefits from test driven development but still have the higher costs. Test-driven development means that you will spend more effort while developing, but will have to spend less on maintaining in the long run. The fun part about home projects is that you don't really have to…

My home projects become tragic when they get past the trival size and I haven't been TDD'ing and designing all the way through. I think part of my problem is that I cannot devote a consistent level of effort every week to my current home project. Sometimes I'll leave and when I come back to it, I'm lost without a test suite and wind up rewriting huge swaths of it. Really good tests also serve as up-to-date documentat…

Spock hacks into Groovy's AST to make labelled expressions have special meanings:

  def "adder-test"() {
    given: "a new Adder class is created"
    def adder = new Adder();

    expect: "Adding two numbers to return the sum"
    adder.add(3, 4) == 7
  }
It could all easily break if the Groovy parser or AST is updated. And very clunky, which says something about Groovy's design post v 1.5.

Re: Giving Up on TDD

#82
post #5

For many paragraphs, I thought this was a parody of TDD defense, but then it turns out it wasn't. His 'defense' of the point is basically: Look, when you do TDD you have to put a lot more work into the tests than you thought! It is not just a simple thing! Okay, fine, but ... Before embarking on TDD, the programmer had a picture in his head of what the costs+benefits of this change would be. Now you are telling him t…

> Because the benefits aren't higher, in fact they are lower It depends on what you think the benefits are. > As usual my advice on this is: look at the people who build things you find highly impressive, and study how they did it. Good idea. Researchers at Microsoft and IBM conducted studies of applying TDD to real, commercial projects of varying sizes, languages, team structure and complexity. They found that defec…

The Nagappan study is one of the few that at least tried to do a decent job, but there ought to be some sort of magic auto-responder every time someone cites it that points out that none of the teams they studied was actually doing "pure TDD" as originally advocated by those who coined the term, so the baseline for all those comparative figures isn't entirely clear.

It's also pertinent that it always seems to be that same one report from nearly a decade ago, studying just a few development groups, that gets cited whenever anyone asks for hard data about the effectiveness of TDD. If TDD is as necessary as its more fervent advocates claim, then surely after all this time we should have a vast body of evidence where real world development teams have tried it and found it clearly superior to what they were doing before, not just a few isolated examples.

Re: Giving Up on TDD

#83
post #78

There's definitely some good points here, but I have a huge issue with this point: > Something that is hard to test is badly designed. In my experience, TDD has a natural tendency to favour decoupling at all costs, and TDD zealots will push de-coupling units as an unqualified positive. And if your metric is "good design = easily testable and low coupling" it certainly looks that way. This mindset fails to take into c…

> In my experience, TDD has a natural tendency to favour decoupling at all costs, and TDD zealots will push de-coupling units as an unqualified positive. And if your metric is "good design = easily testable and low coupling" it certainly looks that way. Depends on the kind of TDD. I feel like TDD as Unit Testing driven design IS a waste of time (I'm talking about unit tests first here). However integration testing fi…

I agree insofar as writing that sort of test prior to writing code that makes your tests pass is a good thing. I don't think that matches the popular definition of TDD though. Most TDD advocates will insist that a key facet of TDD is that NO code exists in your application without first writing a test first. Given that, you're forced either into doing the highly detailed unit tests, or having an integration suite that needs to accomodate for every potential edge case of the entire system underneath it, which for anything non-trivial will be extremely time-intensive to run.

Re: Giving Up on TDD

#84

There's definitely some good points here, but I have a huge issue with this point: > Something that is hard to test is badly designed. In my experience, TDD has a natural tendency to favour decoupling at all costs, and TDD zealots will push de-coupling units as an unqualified positive. And if your metric is "good design = easily testable and low coupling" it certainly looks that way. This mindset fails to take into c…

> This mindset fails to take into consideration the fact that tightly coupled things are often simpler to understand and reason about You're right on a small scale. With teams or feature changes, tightly coupled things quickly breed incidental complexity. I like what you said about decoupling not being unqualified positive. It's not, it's very good, but it's costly (with a high return). It's all about trade offs. Tes…

With teams or feature changes, tightly coupled things quickly breed incidental complexity.

That's a big assumption. However, even if it's correct and tighter coupling does introduce some additional complexity in any given case, if the code is also significantly easier to understand as a result then it may still be quicker and more reliable to maintain it. After all, very loose coupling also breeds a kind of incidental complexity, because something still has to connect all the components.

Re: Giving Up on TDD

#85

Earlier quoted context omitted.

TDD is better than no tests most of the time I think. So at least that's a gain altogether.

It should be noted that TDD specifically means writing tests before you write application code. For example, at our shop, we don't require devs to do TDD, however we require test coverage. I don't think anyone would argue that writing tests at all is a bad idea, I think the debate is whether or not your tests should drive your application code.

I don't think anyone would argue that writing tests at all is a bad idea

If we're talking specifically about the kind of low-level unit tests required for TDD, that is still an assumption, though not an implausible one.

Even if unit testing is effective by some measure, it takes a significant investment of time to create and run those tests. TDD also constrains the software design and the development process.

Maybe we would do better to remove those constraints and instead spend that time on some other activity? Maybe some form of code review or walk-through exercise would be effective. Maybe we should be writing higher-level tests. Maybe we could formally prove some key parts of our code are correct. Learning new programming skills might stop us making some mistakes in the first place. Maybe we should even be adopting a new language or tool that would prevent some errors from being possible at all by design.

There are many ways we can try to make our code more reliable, and they all have costs, and sometimes they conflict. Even if one of them is better than nothing in isolation, that doesn't necessarily make it the best possible strategy when you consider the alternatives and opportunity cost.

Re: Giving Up on TDD

#86
post #56
post #34

Earlier quoted context omitted.

Most software out there has been done without TDD.

Sure, but most software is also pretty bad. Most software projects aren't considered successful. [1] And 99% of people advocating TDD have written software without TDD, so they've tried it both ways. Heck, when anesthesia was introduced, people thought it was a needless luxury and an interference with the pain God intended us to have. [2] And they were right in the way you were right: billions had just lived with the…

Sure, but most software is also pretty bad.

That seems rather uncharitable.

Billions of people travel in software-controlled vehicles every day, and most of them will get to their destination safely and reasonably efficiently.

When I check my bank account or credit card statement, it is extremely unlikely that anything on it is incorrect, even though I may have been transacting with other parties all around the world, with several completely different organisations involved along the way.

When I make my dinner, it is a safe bet that all my kitchen equipment will function properly, even though everything from my microwave to my refrigerator is software controlled.

If I pick up my wireless landline handset and place a call, chances are nothing short of severe interference is going to prevent me from connecting to the phone of the person I want to speak to, again even though this might involve intricate negotiations between numerous devices and even different organisations in different countries.

The world is full of software that is actually pretty good considering it was made by fallible humans. We don't notice a lot of the time, because the things depending on that software just work.

Re: Giving Up on TDD

#87

Earlier quoted context omitted.

> Because the benefits aren't higher, in fact they are lower It depends on what you think the benefits are. > As usual my advice on this is: look at the people who build things you find highly impressive, and study how they did it. Good idea. Researchers at Microsoft and IBM conducted studies of applying TDD to real, commercial projects of varying sizes, languages, team structure and complexity. They found that defec…

The Nagappan study is one of the few that at least tried to do a decent job, but there ought to be some sort of magic auto-responder every time someone cites it that points out that none of the teams they studied was actually doing "pure TDD" as originally advocated by those who coined the term, so the baseline for all those comparative figures isn't entirely clear. It's also pertinent that it always seems to be that…

> none of the teams they studied was actually doing "pure TDD"

And still showed dramatic improvements in defect prevention.

> surely after all this time we should have a vast body of evidence where real world development teams have tried it and found it clearly superior to what they were doing before, not just a few isolated examples.

The problem is funding. Nobody wants to stump up their project for it.

Oh, except at Pivotal, I guess. We've only done a few hundred projects with TDD over several decades. I guess it'll never pan out.

Re: Giving Up on TDD

#88
Moral of the story. Choose simple design, and test your code. Am I missing something?

Btw, this website is great! I really enjoy the writing approach.

Re: Giving Up on TDD

#89

Earlier quoted context omitted.

The Nagappan study is one of the few that at least tried to do a decent job, but there ought to be some sort of magic auto-responder every time someone cites it that points out that none of the teams they studied was actually doing "pure TDD" as originally advocated by those who coined the term, so the baseline for all those comparative figures isn't entirely clear. It's also pertinent that it always seems to be that…

> none of the teams they studied was actually doing "pure TDD" And still showed dramatic improvements in defect prevention. > surely after all this time we should have a vast body of evidence where real world development teams have tried it and found it clearly superior to what they were doing before, not just a few isolated examples. The problem is funding. Nobody wants to stump up their project for it. Oh, except a…

And still showed dramatic improvements in defect prevention.

Right, but because neither what was being tested as close to TDD nor the alternative were fully controlled, we can't tell from the cases studied whether it was the full TDD process that would make a difference, or just writing more unit tests, writing those tests first, writing them at all, or various other changes in process that accompanied the TDD-like shifts.

Oh, except at Pivotal, I guess. We've only done a few hundred projects with TDD over several decades. I guess it'll never pan out.

Good for you. Thousands of other organisations with millions of developers working for them have done thousands of times as many projects as you have without TDD over those same decades, and plenty of them panned out too. Unfortunately, none of those anecdotes in isolation tell us anything very useful about whether things would have panned out better following some other development process.

Re: Giving Up on TDD

#90

Earlier quoted context omitted.

> This mindset fails to take into consideration the fact that tightly coupled things are often simpler to understand and reason about You're right on a small scale. With teams or feature changes, tightly coupled things quickly breed incidental complexity. I like what you said about decoupling not being unqualified positive. It's not, it's very good, but it's costly (with a high return). It's all about trade offs. Tes…

With teams or feature changes, tightly coupled things quickly breed incidental complexity. That's a big assumption. However, even if it's correct and tighter coupling does introduce some additional complexity in any given case, if the code is also significantly easier to understand as a result then it may still be quicker and more reliable to maintain it. After all, very loose coupling also breeds a kind of incidenta…

Interesting point. How about dependency injection for oo code and composition for functional code?
Post reply on HN