3 ms·
Simply put, when I first heard about TDD I got very excited and made the mistakes you would expect a well-intentioned but uninformed person would make: spending
by compay 16y ago
Simply put, when I first heard about TDD I got very excited and made the mistakes you would expect a well-intentioned but uninformed person would make: spending WAY too much time worrying about how to structure my tests correctly, which sometimes distracted me from the "real" problem at hand.
At this point I would certainly not consider myself a great expert on testing, but I think I've acquired a bit more intuition on what and how to test things. I don't usually work in a strictly "test first" manner because often times it's easier for me to "sketch" out a few classes and go through a couple attempts at organizing things before I find an approach that works for me. In these cases, testing first is a pain in the butt.
Other times, for example if I'm implementing some kind of tricky data filter, writing the tests first helps me think about the possible problems I might have to deal with in my implementation.
In general though, my projects usually end up with close to 100% code coverage, even if some of the tests are not very granular. Throughout the lifecycle of the code I maintain, I add tests when fixing bugs to avoid regressions. The tests that I write obviously don't catch every bug, but they do usually stop me from making embarrassing, silly mistakes which I think covers a pretty significant percentage of bugs in general. I don't usually have to worry about breaking things when refactoring or adding new features, which is a great feeling that I pretty much never felt in either my "no testing" or "way too much testing" phases.
So basically I have a very pragmatic attitude towards testing which I think would be non-threatening to a skeptic like yourself. :-) Part of the problem is that you might be letting yourself get turned off to valuable and useful techniques, not because of the techniques themselves, but the way in which they are being presented to you.
But at the end of the day, you have to find whatever works best for you to make the best code you can, and don't worry about what other people think.
- torial 16y agoI've been following the TDD stuff as an outsider, and hands down the article that makes me consider it with the least skepticism is this one: http://blog.objectmentor.com/articles/2009/10/07/tdd-derangement-syndrome http://blog.objectmentor.com/articles/2009/10/07/tdd-derange... I'm sure there are issues w/ the various studies it cites, but it is the only one to actually address TDD from a productivity standpoint with some research data that I've seen. (More / better links welcome too!)
- apu 16y agoNot to get sucked into a debate about TDD stuff, but to me the following blog post said all that needs to be about at least the TDD business and "gurus" (if not the whole methodology): http://ravimohan.blogspot.com/2007/04/learning-from-sudoku-solvers.html http://ravimohan.blogspot.com/2007/04/learning-from-sudoku-s...
- compay 16y agoI agree to an extent - I just think it says a lot more about the individuals than the methodology. TDD doesn't magically transform bad solutions to good ones, and nobody should claim or expect that. It's a shame that what is really just a useful technique has been overhyped by people trying to make a buck.
- torial 16y agoI'd take the imperfect studies listed in the article I provided over two anecdotes. However, for the scenario of using TDD with the Sudoku, where it was done with less chaos, other anecdotes are there: http://johannesbrodwall.com/2010/04/06/why-tdd-makes-a-lot-of-sense-for-sudoko/ http://johannesbrodwall.com/2010/04/06/why-tdd-makes-a-lot-o... I say this as a person who likes Norvig more than I like TDD (I'm interested in TDD to see if it is useful for my day to day work, Norvig is more of my high level guilty pleasure, such as his spell checker article or his speech on using lots of data and then algorithm becomes less important)