Live data from Hacker News

Test-Driven Development is Stupid

geometrian.com

81–90 of 154 posts

Re: Test-Driven Development is Stupid

#81

> You are writing code to test something that doesn't even exist yet. I am not rightly able to apprehend the kind of confusion of ideas that could provoke such a method. Yeah, the fact that you can't comprehend why people do this is very clear; if you could, you wouldn't have written this terrible rant. It feels like the author is criticizing this before coming anywhere close to understanding why people do it. I real…

>You are writing code to test something that doesn't even exist yet. To piggyback on this... sure, the code doesn't exist yet, but the project specs do. And unit tests can help by making the required specification explicit.

In any other field, specifying a function by its value at a handful of points would be a bad joke.

If you don't know what you want your code to do then tests will just make it harder to experiment, and if you do know then there's no harm in writing them after the fact.

Re: Test-Driven Development is Stupid

#82
post #19

Earlier quoted context omitted.

I think you're missing the most important one: ensuring you don't unexpectedly break your own code in the future (when you come back in 6 months and forget why exactly it's arr[1:n-1] not arr[0:n-1] or arr[1:n]).

Sounds like a well placed comment would be of more value than a test there.

[deleted]

Re: Test-Driven Development is Stupid

#83

> You are writing code to test something that doesn't even exist yet. I am not rightly able to apprehend the kind of confusion of ideas that could provoke such a method. Yeah, the fact that you can't comprehend why people do this is very clear; if you could, you wouldn't have written this terrible rant. It feels like the author is criticizing this before coming anywhere close to understanding why people do it. I real…

Yes. I was going to come on here and say the same thing: this guy doesn't know what the heck he is talking about.

Your point is an excellent one. If you see hundreds of really smart people doing X and seemingly very happy with it, there's probably something going on there that's more important than just a bunch of fools with a fad. It might not be appropriate in your situation, it might be oversold by those folks -- but it's highly unlikely that's it's stupid and dumb.

I work with training developers all the time. It continues to amaze me how people go from being a novice to being an expert. One day they can't code at all. Next day they know everything there is to know about it -- and can go on at length about why process X is a terrible thing, without even trying or understanding it.

Of course, we have the opposite problem in development also. People get sold on ideas that will never work simply because they sound cool or the cool kids are doing them. This reminds me of the old saying "Always be open-minded -- just not empty-headed"

Re: Test-Driven Development is Stupid

#84

Way stronger than I'd write, and I don't agree with it entirely, but the author has a point. Personally, what annoys me the most about TDD I've seen in the wild are two things: designing for tests instead of actual problems, and tests affecting the structure of "real" code. Designing for tests - the standard TDD approach, first we write tests, then we write code to pass the tests. Quite often the consideration of the…

> Tests affecting the structure […] is […] a strong code smell

On the other hand, code being hard or impossible to test is often thought of as a code smell as well. Code that is easy to test is easier to understand — not in the least because there are tests demonstrating its use. Techniques such as dependency injection help a lot here.

Re: Test-Driven Development is Stupid

#85

When I read these kind of articles I'm always curious to see the professional background of the author. Not to criticize, but to see if he/she's talking about something he/she saw in scale or not. Because if you're working with a very small code base then I may even understand sentences like "I am against unit tests in general". I've never met people who work (or worked) in very large companies being against, at leas…

None. He's still in university. [0]

[0] http://geometrian.com/about/cv.pdf

Re: Test-Driven Development is Stupid

#86
Ok so I read the first sentence and felt it set the tone of the paper. Continued reading and it pretty much played out exactly as I thought it would.

>"Trying to improve software quality by increasing the amount of testing is like try[ing] to lose weight by weighing yourself more often."

So this is really funny to me because I just read an article that in fact states that weighing yourself more often does help people lost weight. http://www.sciencedaily.com/releases/2015/06/150617134622.ht...

Just by looking at the page and the style of reading you can tell this is someone who has not progressed in their career skills since the early 90's

Re: Test-Driven Development is Stupid

#87

> You are writing code to test something that doesn't even exist yet. I am not rightly able to apprehend the kind of confusion of ideas that could provoke such a method. Yeah, the fact that you can't comprehend why people do this is very clear; if you could, you wouldn't have written this terrible rant. It feels like the author is criticizing this before coming anywhere close to understanding why people do it. I real…

Yes. I was going to come on here and say the same thing: this guy doesn't know what the heck he is talking about. Your point is an excellent one. If you see hundreds of really smart people doing X and seemingly very happy with it, there's probably something going on there that's more important than just a bunch of fools with a fad. It might not be appropriate in your situation, it might be oversold by those folks --…

> It continues to amaze me how people go from being a novice to being an expert. One day they can't code at all. Next day they know everything there is to know about it -- and can go on at length about why process X is a terrible thing, without even trying or understanding it.

The Dunning-Kruger effect in action.

Re: Test-Driven Development is Stupid

#88
TDD has always looked to me like a good idea taken to ridiculously dogmatic extremes (a very common occurrence in software development, IMHO), but I think many of this author’s indiscriminate potshots miss the most important problems.

In order to write a test for something, you need to know what it is supposed to do, and testing will not tell you that. In order to make something that passes your tests, you have to design it, and a test does not tell you what that design should be - it can tell you if you failed in a specific way, but not what to do about it. There is a whole lot of analytical reasoning and technical judgement to software development that is ignored by TDD, and while thinking about test cases can help with this, it is an insufficiently powerful method to complete the job.

Agile methods have not rescinded this fact. Insofar as they form a complete development methodology (and I am not sure about that), they offer an empirical approach to discovering your requirements (which may or may not be appropriate to your situation), and the use of short-cycle iteration to gauge how you are progressing, but they are largely silent on the issues I raised above.

Re: Test-Driven Development is Stupid

#90

Way stronger than I'd write, and I don't agree with it entirely, but the author has a point. Personally, what annoys me the most about TDD I've seen in the wild are two things: designing for tests instead of actual problems, and tests affecting the structure of "real" code. Designing for tests - the standard TDD approach, first we write tests, then we write code to pass the tests. Quite often the consideration of the…

> Tests affecting the structure […] is […] a strong code smell On the other hand, code being hard or impossible to test is often thought of as a code smell as well. Code that is easy to test is easier to understand — not in the least because there are tests demonstrating its use. Techniques such as dependency injection help a lot here.

The effect that I'm complaining here is visible in "weaker" languages, like Java. People are too afraid to use reflection to instrument the code for testing, so e.g. in a codebase I'm working on right now at $JOB I get to see classes in which you can't really tell what code is there for business purposes and what code was added so that the business code could be tested.

I agree with you that a code that's hard or impossible to test is a code smell. I argue that having to modify a good design to accomodate for more testing is also a code smell. I think the two heuristics narrow down the design space nicely, pointing one towards designs that are easy to test because of their natural boundaries, and not because of additional testing cruft being added.

Post reply on HN