News for hackers. Stuff that matters.
Re:"Joel Spolksy is wrong about my work" - Kent Beck by axod on Wednesday February 04, 2009 @09:15AM (#465743)
>> "Before the changes you have code that you know works. After the changes, you know where most of the bugs are because your tests tell you where they are."

No. More often than not, if you change was a large architectural one, which is often the case in young software, your tests are now irrelevant, or broken.

>> "It's the difference between walking with your eyes open or closed... it may be more work to process all that information about obstacles, but it sure is helpful if you want to avoid those obstacles."

Do you seriously think people are just blindly coding and never testing anything here?

  while(true) {
    writeABitOfCode();
    while (!compile()) fixCompilationErrors();
    testThingsYouMightHaveChanged();
    checkLogsForIssues();
  }
Re:"Joel Spolksy is wrong about my work" - Kent Beck by swombat on Wednesday February 04, 2009 @09:42AM (#465784)
* testThingsYouMightHaveChanged();*

If you change that into writeAnAutomatedTestForItAndRunYourTestSuite() you get the following benefits:

1) Every test you write accrues value onto your test suite and helps you avoid problems later;

2) You don't need to spend time to figure out what you might have broken with your change - your test suite tells you in seconds;

3) You can say with some measure of certainty that it's extremely unlikely that your change broke anything.

Re:"Joel Spolksy is wrong about my work" - Kent Beck by axod on Wednesday February 04, 2009 @11:30AM (#465939)
BUT you then have to modify:

  while (!compile()) {
    fixCompilationErrors();
    fixUnitTests();
    rewriteUnitTestsThatNoLongerMakeSense();
    WriteNewUnitTests();
  }
Your iterate loop just became maybe twice or 3 times as long. Less iterations = worse code.
Re:"Joel Spolksy is wrong about my work" - Kent Beck by Retric on Wednesday February 04, 2009 @11:51AM (#465987)
rewriteUnitTestsThatNoLongerMakeSense

Delete em. You should be iterating your unit tests.

Over time you will find some really useful unit tests for common mistakes, and others that are basically useless. Try and approach things from the perspective of what you would like to know works and not just tossing everything and the kitchen sink at the problem. When you find a bug add a unit test just in case it comes back, if you change major parts of the system, port the most useful unit tests and delete the rest.

I think of unit tests as saving you from the (I thought I just fixed this) problem.

PS: The major advantage of this approach is you keep adding more tests to the older parts of the system, which are also the most costly to change because other parts of the system assume it works. And assumptions you and your code is making can be really hard bugs to find and fix.

Re:"Joel Spolksy is wrong about my work" - Kent Beck by nostrademons on Wednesday February 04, 2009 @01:09PM (#466166)
I think the best benefit of unit tests is really saving you from the "Will this break anything?" problem. Uncertainty is the real big killer for programming productivity; if you know what to code, you just type it out and you can get like 10 lines/minute. So have some way that you can run things and say "I know this broke something" or "I know this didn't break anything."
Re:"Joel Spolksy is wrong about my work" - Kent Beck by DougBTX on Wednesday February 04, 2009 @01:38PM (#466223)
testThingsYouMightHaveChanged requires running your tests manually, which is slow and hard to fully reproduce later. It also depends on being able to make strong predictions about what your change affects, unit testing assumes that anything could have broken.