Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
What Iím saying is that this doesnít strike me as a danger of TDD so much as a danger of not thinking.

Weeeell. Maybe. I think the difference testing code and testing specs is quite a subtle one - not one I would characterise as people not thinking.

  1. I have a requirement. I write a test to illustrate part of that requirement. I then write the minimal code I need to write to make that test pass - refactoring as I go.
  2. I have a requirement. I need to write some code to meet that requirement. I write a test that will fail without that code. I write the code.

(1) is TDD. (2) is just writing the the test before your code.

I've encountered a several people who say they're doing TDD when they're doing (2). It was certainly a stage I went through when I started down the TDD road.

It's an easy trap to fall into. Well, more of a local maxima than a trap. (2) is still good - much better than not writing tests, or writing tests post-code. But it's not TDD because the design is not being driven by the tests, so you miss out on all the benefits that gives you.

I agree this is not a danger of TDD. It's a danger of doing something that looks like TDD but isn't. Describing it as a danger of TDD is counter productive. People tend to read it as "I should not do FOO because BAR will happen" rather than "If BAR happens than I'm not doing FOO correctly".

However I do find these consequences interesting. The places where people are doing wrong when they think they're doing right are useful areas to explore for at least two reasons.

Firstly they highlight areas where people learning a practice can go wrong.

One of the questions I regularly ask when I'm introducing people to TDD is "Why did you write that test?". If the answer is something like "Because the store can receive multiple orders at the same time" then things are probably going okay. If the answer is "Because I need to add an array to keep both orders" then some gentle nudging might be in order.

Secondly they highlight areas where we might need additional mechanisms to catch the errors.

For example the problem of the programmer tests and the spec getting radically out of sync doesn't tend to happen in groups doing Extreme Programming because they have additional practices (customer tests, not restricting TDD to just unit tests, short iterations, etc.) that catch these problems early or prevent them happening in the first place.

In reply to Re^5: A danger of test driven development. by adrianh
in thread A danger of test driven development. by Perl Mouse

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2019-11-13 18:11 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (74 votes). Check out past polls.