1

This is a paragraph from Kent Beck's book on Test Driven Development:

Clean code that works – now. This is the seeming contradiction that lies behind much of the pain of programming. Test-driven development replies to this contradiction with a paradox – test the program before you write it.

What is the seeming contradiction in the first line of the above paragraph? If I take the meaning of seeming as apparent, I don't see the connection between seeming and contradiction in the above paragraph. What is it that is apparently contradictory in that line?

4
  • 1
    If you don't write the program, how can you test it? You have to write it, compile it, & then test it. If you don't, then, it seems, you can't test it. That's the contradiction. But Beck's gonna show you how to test a program that doesn't exist.
    – user21497
    Commented Mar 5, 2013 at 14:58
  • @BillFranke where has he mentioned about writing code?
    – Geek
    Commented Mar 5, 2013 at 14:59
  • 2
    "test the program before you write it."
    – user21497
    Commented Mar 5, 2013 at 15:02
  • 1
    Also, from the publisher: Readers will learn to: Solve complicated tasks, beginning with the simple and proceeding to the more complex. Write automated tests before coding. Grow a design organically by refactoring to add design decisions one at a time. Create tests for more complicated logic, including reflection and exceptions. Use patterns to decide what tests to write. Create tests using xUnit, the architecture at the heart of many programmer-oriented testing tools.
    – user21497
    Commented Mar 5, 2013 at 15:05

1 Answer 1

3

The contradiction he's referring to is the tension between having code that works right, and having it quickly (with the added constraint of wanting code that's "clean"---readable, documented, easy to change latter, and so on). Calling it a contradiction is a bit of a leap, perhaps even hyperbole, but programmers are used to having to choose between getting code written quickly and writing code that's bug free.

(The comments suggesting that writing tests before coding is the contradiction are mistaken; that is the "paradox" which is a response to the "contradiction".)

8
  • Readers who reviewed the book are a bit more specific than the publisher's jacket comments & much more specific than you are, & they didn't anti-Rumpelstiltskin the language into straw to match their ideas instead of the author's. He didn't say that writing tests was possible without code but that it was possible to test portions (modules/routines) of the program before writing the program, not before writing any of the code. The "mistake" here is not knowing when to read something literally & when figuratively. The Q is: "What did the author say?", not "What do I think?"
    – user21497
    Commented Mar 5, 2013 at 23:30
  • @BillFranke: "Test-driven development replies to this contradiction". So test-driven development cannot itself be the contradiction. "This" is the seeming contradiction, where "This" can only refer to what has appeared previously: "Clean code that works – now". As for your complaint that "He didn't say that writing tests was possible without code", I can only think that you're referring to my comment about "writing tests before coding", which you will note is almost word for word from the publisher's comment you quoted above.
    – Henry
    Commented Mar 5, 2013 at 23:37
  • Yes, but what the author means -- and I don't know what the books specifically says, so it's possible that the copy editor who decided what the book jacket would say merely paraphrased what the author says -- is that it's not necessary to code the entire program before you test it: all that's necessary is to test what are probably going to be problematic routines. This is strictly a matter of the semantics of the language used, not the logic of programming. Almost word for word is akin to Close, but no cigar.
    – user21497
    Commented Mar 5, 2013 at 23:52
  • Reader/Reviewer Thomas Koenig says: "TDD fits development into a three micro-phase cycle: create a test that embodies your requirement, write code that passes the test, make the code run clean". The code he's talking about is the small bit of test code, not the full final program code.
    – user21497
    Commented Mar 5, 2013 at 23:54
  • @BillFranke: You seem to be arguing with me about what TDD is, and I don't know why. Your characterization of how TDD works is neither controversial nor relevant. The issue is the first two sentences, in the original quote, which are about programming in general, not about TDD. As for "writing tests before coding", 1) I have no idea why you're quibbling about a minor point in my off-hand description of TDD, 2) the only word I omitted is "automated", whose presence would add irrelevant detail, and whose absence does not change the meaning of the sentence.
    – Henry
    Commented Mar 6, 2013 at 2:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .