Live data from Hacker News

Test-Driven Development Bypasses Your Brain

stoneship.org

11–20 of 67 posts

Re: Test-Driven Development Bypasses Your Brain

#11
TDD in theory is a great idea. In practice it is dreadful.

Because what has happened is that the obsession with code coverage has meant that developers create a whole raft of tests that serve no real purpose. Which due to TDD then gets translated into unworkable, unwieldy spaghetti like mess of code. Throw in IOC and UI testing e.g. Cucumber and very quickly the simplest feature takes 5x as long to develop and is borderline unmaintainable.

It just seems like there needs to be a better way to do this.

Re: Test-Driven Development Bypasses Your Brain

#12
post #2

I don't recall ever reading that just because you have tests, you should no longer understand the processes by which your code functions. Was this something that they've seen happen, or experienced personally?

I have occasionally been tempted into the mindless code modifying that I described. That is in the past though!

More importantly, I have also seen this happen in professional environments. A very large test suite is very useful, but it is absolutely not a catch-all safety net.

Re: Test-Driven Development Bypasses Your Brain

#13

TDD is good for verifying that your code handles the set of requirements given by the customer - including any edge cases that matter to them. I probably agree that 100% test passes doesn't equal no bugs. Nonetheless, it's still useful! You can still write TD code and use your brain - it is only slightly easier to be lazy (and specifically, lazy in a way you're not supposed to care about, yet.) In the end, production…

> I probably agree that 100% test passes doesn't equal no bugs.

TDD never promised that, and practitioners of TDD understand that 100% coverage doesn't mean you won't have bugs. This doesn't invalidate the TDD or testing (as you are obviously aware of =)).

Re: Test-Driven Development Bypasses Your Brain

#14
post #8
post #2

I don't recall ever reading that just because you have tests, you should no longer understand the processes by which your code functions. Was this something that they've seen happen, or experienced personally?

I suspect the linked article is a straw-man built to provoke responses, and thereby create page views for the blog.

I suspect your comment adds absolutely nothing to the conversation. If you disagree with the premise then how about explaining why you think TDD is the panacea for poor software quality.

Re: Test-Driven Development Bypasses Your Brain

#15
post #8
post #2

I don't recall ever reading that just because you have tests, you should no longer understand the processes by which your code functions. Was this something that they've seen happen, or experienced personally?

I suspect the linked article is a straw-man built to provoke responses, and thereby create page views for the blog.

I (sadly) average 1 article written per 3 years, so there wouldn’t be much of a point in creating page views.

Re: Test-Driven Development Bypasses Your Brain

#16
This article misunderstands TDD completely. In TDD, the tests are your specifications. Therefore, any code that passes the tests is formally correct - even though it should always be minimal (YAGNI).

In fact, TDD is not simply "tests first". It is: write ONE test, make it pass with the MINIMUM amount of code, refactor, loop.

Re: Test-Driven Development Bypasses Your Brain

#17

Personally I completely disagree with this, I've never found myself randomly changing code in a desperate attempt to get a test to pass. Maybe it's because I'd been coding for years before I ever tried TDD, but when a test fails, I logically debug the code the same way I would if I wasn't using TDD. As far as I'm concerned having tests just flags possible errors much quicker, and also gives me more piece of mind that…

An often touted "benefit" of TDD is that "addictive" feeling when you write tests and see them pass. "you feel like you have done a lot because you have a lot of code"; "you feel a great deal of accomplishment". Quite a few pages talk about it when you search for "tdd addictive".

The canonical example is the master of XP solving Sudoku in the TDD way: http://xprogramming.com/articles/oksudoku/ (part 1 out of 5) -vs- Peter Norvig: http://norvig.com/sudoku.html

Re: Test-Driven Development Bypasses Your Brain

#18

Personally I completely disagree with this, I've never found myself randomly changing code in a desperate attempt to get a test to pass. Maybe it's because I'd been coding for years before I ever tried TDD, but when a test fails, I logically debug the code the same way I would if I wasn't using TDD. As far as I'm concerned having tests just flags possible errors much quicker, and also gives me more piece of mind that…

I believe it boils down to a matter of discipline.

If you say that you never randomly modify code in order to make it work (according to the tests), then that is great, and that is how every developer should work. However, my experience is that people who lack discipline (or face a looming deadline) tend to not take their time to properly reason about code and instead rely on the test suite to tell them whether code is right or not.

Re: Test-Driven Development Bypasses Your Brain

#20
The author made one slight mistake: he wrote "there is a tendency to mindlessly modify code" instead of "I have a tendency to mindlessly modify code".

Also, it's not like this we haven't seen this kind of behavior decades before the invention of TDD.

This is just another example of a craftsman blaming his tools. TDD is not a silver bullet, but no method or tool can serve as an excuse for mindlessly poking around until it works. This isn't limited to programming either.

Post reply on HN