TDD doesn't suck

Discussion in 'C Programming' started by Phlip, Aug 10, 2006.

  1. Phlip

    Phlip Guest

    Cers:

    The majority of the world's legacy software is written in C.

    However, the market leader in new code is Java. The language is technically
    inferior, and its success depends on two props. One of them is Sun's
    marketing machine.

    The other is JUnit. This is the flagship system in a host of Free Software
    tools that assist Test Driven Development. It leads related tools, like
    CruiseControl and Fitnesse, which help Java shops rapidly ship stable
    software, overcoming the language's technical problems.

    Put another way, the unique power of TDD to avoid debugging and streamline
    development is partly responsible for Java's false appearance of success.
    When you see Java's numbers, you see an effect of TDD.

    So it seems to me that people interested in maintaining majority of the
    world's legacy codebases, and people interested in competing with Java via
    technology (not marketing), would do well to learn TDD.

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 10, 2006
    #1
    1. Advertising

  2. Phlip

    Al Balmer Guest

    On Wed, 09 Aug 2006 23:01:35 GMT, "Phlip" <> wrote:

    >Cers:
    >
    >The majority of the world's legacy software is written in C.
    >

    If you think that statement makes your post topical, you're wrong.

    --
    Al Balmer
    Sun City, AZ
     
    Al Balmer, Aug 10, 2006
    #2
    1. Advertising

  3. Phlip said:

    > Cers:
    >
    > The majority of the world's legacy software is written in C.
    >
    > However, the market leader in new code is Java.


    Java - a language which, in theory, has no pointers. But many of us have
    seen the "Java null pointer exception" message at the bottom of a public
    access terminal screen and "out of order" scrawled on a piece of card to
    warn you away. If you wanted a good showcase for TDD, I think you picked
    the worst possible example.

    > Put another way, the unique power of TDD to avoid debugging


    ....appears to result in buggy software. See above.

    If you want to sell TDD in comp.lang.c, (a) don't, but (b) if you're going
    to ignore that advice anyway, at least sell it in comp.lang.c terms, by
    providing an example implementation of TDD written in very, very portable
    ISO C.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Aug 10, 2006
    #3
  4. Phlip

    Phlip Guest

    Richard Heathfield wrote:

    >> The majority of the world's legacy software is written in C.
    >>
    >> However, the market leader in new code is Java.

    >
    > Java - a language which, in theory, has no pointers. But many of us have
    > seen the "Java null pointer exception" message at the bottom of a public
    > access terminal screen and "out of order" scrawled on a piece of card to
    > warn you away. If you wanted a good showcase for TDD, I think you picked
    > the worst possible example.


    I never said Java was invented with TDD.

    TDD currently props up much of the development in an otherwise sucky
    language. The language's low quality requires the high quality of TDD just
    to break even.

    I suspect I made that point very clearly, in the prose you snipped.

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 10, 2006
    #4
  5. Phlip

    Phlip Guest

    Richard Heathfield wrote:

    > If you want to sell TDD in comp.lang.c, (a) don't, but (b) if you're going
    > to ignore that advice anyway, at least sell it in comp.lang.c terms, by
    > providing an example implementation of TDD written in very, very portable
    > ISO C.


    That's a non-sequitur. TDD is a technique, not a piece of code. And you are,
    again, muddying the topicality issue, by appealing to portability.

    A test rig for C appears here:

    http://sourceforge.net/projects/cut

    It enables the TDD coding cycle, but I don't know where any source code
    produced thusly is. What would such code prove?

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 10, 2006
    #5
  6. Richard Heathfield <> wrote:

    > Java - a language which, in theory, has no pointers. But many of us have
    > seen the "Java null pointer exception" message at the bottom of a public
    > access terminal screen and "out of order" scrawled on a piece of card to
    > warn you away. If you wanted a good showcase for TDD, I think you picked
    > the worst possible example.


    <ot>I don't think the case for or against TDD has anything to do with
    the dreaded NPE. C has just as many errors caused by dereferencing
    null pointers, except that Java helpfully throws an exception rather
    than unleashing nasal daemons.

    > > Put another way, the unique power of TDD to avoid debugging

    > ...appears to result in buggy software. See above.


    TDD does not preclude the need for debugging, if only because mere
    mortals are as unlikely (on the first try) to code the test correctly
    as they are the actual code.</ot>

    > If you want to sell TDD in comp.lang.c, (a) don't, but (b) if you're going
    > to ignore that advice anyway, at least sell it in comp.lang.c terms, by
    > providing an example implementation of TDD written in very, very portable
    > ISO C.


    TDD doesn't seem to be a paradigm well-suited for C, since many of the
    language features that make Java amenable to TDD (language support
    and/or syntactic sugar to facilitate OOP, exceptions, etc.) are not
    available in C.

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Aug 10, 2006
    #6
  7. Phlip <> wrote:

    (WRT TDD in Java)

    > TDD currently props up much of the development in an otherwise sucky
    > language. The language's low quality requires the high quality of TDD just
    > to break even.


    Perhaps you'd like to take your opinions regarding what makes Java
    "sucky" to a different venue? (Followups set to
    comp.lang.java.programmer, if you're so inclined.)

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Aug 10, 2006
    #7
  8. Phlip

    Ian Collins Guest

    Christopher Benson-Manica wrote:
    >
    > TDD doesn't seem to be a paradigm well-suited for C, since many of the
    > language features that make Java amenable to TDD (language support
    > and/or syntactic sugar to facilitate OOP, exceptions, etc.) are not
    > available in C.
    >

    I agree with some of this, C doesn't fit well with the <pick your
    language>Unit frameworks.

    My workaround is to use a C++ framework for the tests. Sounds messy but
    works well. I'm sure many C programmers would prefer an all C solution.

    --
    Ian Collins.
     
    Ian Collins, Aug 10, 2006
    #8
  9. Phlip said:

    <snip>
    >
    > A test rig for C appears here:
    >
    > http://sourceforge.net/projects/cut


    Thank you. I'll take a closer look if and when I get time, energy,
    motivation and coffee in the right mix. Incidentally, my principal
    objection to your TDD evangelism is that it is too woolly; in the past,
    you've appeared (to me at least) to be evasive when it comes down to actual
    details of how to /do/ TDD. Now that you've shown me your source code, you
    may just have a convert - but don't hold your breath, as I have other stuff
    to do in the next week or three, so "cut" will have to wait a while.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Aug 10, 2006
    #9
  10. Christopher Benson-Manica <> writes:
    > Phlip <> wrote:
    >
    > (WRT TDD in Java)
    >
    >> TDD currently props up much of the development in an otherwise sucky
    >> language. The language's low quality requires the high quality of TDD just
    >> to break even.

    >
    > Perhaps you'd like to take your opinions regarding what makes Java
    > "sucky" to a different venue? (Followups set to
    > comp.lang.java.programmer, if you're so inclined.)


    I've set followups back to comp.lang.c.

    Whatever you may think of the topicality or appropriateness of Phlip's
    posting, he was smart enough *not* post a statement that Java is
    "sucky" to comp.lang.java.programmer. You, however, chose to quote
    that statement and dump it into that newsgroup. This is inappropriate
    and trollish. One might assume you're trying to start a flame war; I
    hope the folks in cljp don't take you up on it.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Aug 10, 2006
    #10
  11. Phlip

    Chris Dollin Guest

    Richard Heathfield wrote:

    > Phlip said:
    >
    >> Cers:
    >>
    >> The majority of the world's legacy software is written in C.
    >>
    >> However, the market leader in new code is Java.

    >
    > Java - a language which, in theory, has no pointers.


    Java is /littered/ with pointers. What it doesn't have is pointer
    arithmetic. Different choices for different styles of programming.

    > But many of us have
    > seen the "Java null pointer exception" message at the bottom of a public
    > access terminal screen and "out of order" scrawled on a piece of card to
    > warn you away.


    (Really? Coo. That would be gobsmackingly stupid code that can't handle
    an exception at the top level. Oh well, life is full of suprises.)

    > If you wanted a good showcase for TDD, I think you picked
    > the worst possible example.


    I am much less certain that Phlip is that widespread Java code has
    been built using TDD (even if it is JUnited). I think we have a
    clear case of not being able to tell ...

    >> Put another way, the unique power of TDD to avoid debugging

    >
    > ...appears to result in buggy software. See above.


    No evidence from the above. (Anecdotally, /I/ have found using TDD has
    helped /my/ Java software development, and I wouldn't work in Java
    without it (or a superior substitute if one appeared)).

    > If you want to sell TDD in comp.lang.c, (a) don't, but (b) if you're going
    > to ignore that advice anyway, at least sell it in comp.lang.c terms, by
    > providing an example implementation of TDD written in very, very portable
    > ISO C.


    [Nitpick: you don't implement TDD; you implement the test framework, and do
    TDD over it.]

    I want one.

    --
    Chris "but I also want exceptions" Dollin
    Meaning precedes definition.
     
    Chris Dollin, Aug 10, 2006
    #11
  12. In comp.lang.c Keith Thompson <> wrote:

    > Whatever you may think of the topicality or appropriateness of Phlip's
    > posting, he was smart enough *not* post a statement that Java is
    > "sucky" to comp.lang.java.programmer. You, however, chose to quote
    > that statement and dump it into that newsgroup. This is inappropriate
    > and trollish. One might assume you're trying to start a flame war; I
    > hope the folks in cljp don't take you up on it.


    What I really wanted was simply for OP to elaborate on the statement -
    I'm genuinely interested to know what about Java OP believes is
    fundamentally bad. I suppose I would have been better off directing
    the conversation to, say, comp.programming, but surely we can at least
    agree that comp.lang.c isn't the place to continue the discussion.

    --
    C. Benson Manica | I *should* know what I'm talking about - if I
    cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Aug 10, 2006
    #12
  13. In article <> lid writes:
    > Phlip said:
    >
    > <snip>
    > >
    > > A test rig for C appears here:
    > >
    > > http://sourceforge.net/projects/cut

    >
    > Thank you. I'll take a closer look if and when I get time, energy,
    > motivation and coffee in the right mix.


    There actually is not much activity there. I see two open calls in the
    bug tracking system, both over three years old. And the last release
    is also over three year old. And since over a year the documentation
    is no longer available, the only documentation available is the Readme
    file for the oldest version. So you can have a closer look, but the only
    thing you will find is the source and another Readme file.
    --
    dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
    home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
     
    Dik T. Winter, Aug 10, 2006
    #13
  14. Phlip

    Phlip Guest

    Dik T. Winter wrote:

    > > > http://sourceforge.net/projects/cut


    > There actually is not much activity there.


    This thread ain't about what's the best C unit test rig. Google says this
    one is:

    http://cutest.sourceforge.net/

    Curiously, JUnit is humongous and full of features, and these C versions are
    tiny. All a unit test rig needs to do is enable the Test/Code/Refactor
    cycle, so maybe JUnit is big because Java is a superior language. ;-)

    Christopher Benson-Manica wrote:

    > What I really wanted was simply for OP to elaborate on the statement -
    > I'm genuinely interested to know what about Java OP believes is
    > fundamentally bad.


    Richard Heathfield said it best: Java - a language which, in theory, has no
    pointers. But many of us have seen the "Java null pointer exception" message
    at the bottom of a public
    access terminal screen...

    So Sun invented Java to fit the marketing pitch "this language is safer than
    that horrible C++, which slows your engineers down with lots of bugs".
    Defining Java in the negative - removing innocent features from C++ and
    adding nothing - simply left Java open to grow a whole new category of bugs.

    > TDD does not preclude the need for debugging, if only because mere
    > mortals are as unlikely (on the first try) to code the test correctly
    > as they are the actual code.


    Under TDD, you run all tests after the fewest possible edits. Usually less
    than 10 statements, copies, etc. When a test fails unexpectedly, you only
    have <10 edits to throw away, before all the tests pass.

    You shouldn't even need to inspect the error to make the tests pass again.

    With or without TDD, if you discover a bug that tests didn't catch, you must
    debug, because you must preserve your investment in all the edits you made
    between adding that bug and finding it. So "debug" means run the debugger,
    add trace statements, and sleuth out the cause. Then it means fix the bug
    without adding more bugs.

    So the knob to set here is how proactive you want your tests, to improve the
    odds you find your bugs as early as possible. As you write more tests first,
    the rate of long-term bugs goes down, and the rate of punitive debugging
    goes down.

    Teams using TDD overwhelmingly report much less time spent debugging. Some
    report they can code for years, and frequently ship product, without ever
    activating a debugger.

    Legacy situations typically require debugging, to research what's going on.
    C is used close to the metal, so a C team using TDD would not expect to
    never invoke a debugger. They would, however, report fewer instances of
    punitive debugging.

    Ian Collins wrote:

    > My workaround is to use a C++ framework for the tests. Sounds messy but
    > works well. I'm sure many C programmers would prefer an all C solution.


    Here's a unit test for a C framework (based on Gtk+) using an all-C test
    rig:

    TEST_NEW (dia_canvas_item_create)
    {
    DiaCanvasItem *ti1 = NULL;
    DiaCanvasItem *ti2 = NULL;

    ti1 = dia_canvas_item_create (TYPE_TEST_ITEM, NULL);
    TEST (ti1->parent == NULL);
    TEST (ti1->canvas == NULL);
    TEST (G_OBJECT (ti1)->ref_count == 1);

    ti2 = dia_canvas_item_create (TYPE_TEST_ITEM, "parent", ti1, NULL);
    TEST (ti2->parent == ti1);
    TEST (TEST_ITEM (ti1)->children->data == (gpointer) ti2);

    TEST (G_OBJECT (ti1)->ref_count == 1);
    TEST (G_OBJECT (ti2)->ref_count == 2);

    g_object_unref (ti1);
    }

    It tests that dia_canvas_item_create() creates a child item, then creates a
    parent item with its child pointer set to the child.

    Under TDD, if you didn't have that feature yet, you would write such a test
    and get the TEST() lines to fail. (Those should generally be called
    CHECK().) Then you write code to pass the test. Because you only write such
    code to respond to a failing test, the tests touch every feature you need.

    Richard Heathfield wrote:

    > ...in the past,
    > you've appeared (to me at least) to be evasive when it comes down to
    > actual
    > details of how to /do/ TDD.


    > Now that you've shown me your source code...


    Oh dear. I didn't write CUT. I did prompt Arjan Molenaar to write the
    DiaCanvas tests, but he didn't get the "first part".

    I humbly submit the following, which I _did_ write, to make up for my
    wooliness:

    http://flea.sourceforge.net/TDD_in_a_nut_shell.pdf


    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 10, 2006
    #14
  15. Phlip

    goose Guest

    Phlip wrote:
    > Richard Heathfield wrote:
    >
    > > If you want to sell TDD in comp.lang.c, (a) don't, but (b) if you're going
    > > to ignore that advice anyway, at least sell it in comp.lang.c terms, by
    > > providing an example implementation of TDD written in very, very portable
    > > ISO C.

    >
    > That's a non-sequitur. TDD is a technique, not a piece of code.


    Which, I believe, makes it off-topic in clc. After all,
    tail-recursion optimisation, building via makefiles vs IDE project
    files, source control methods and forking (and/or threading)
    are all also techniques and all equally off-topic.

    > And you are,
    > again, muddying the topicality issue, by appealing to portability.
    >
    > A test rig for C appears here:
    >
    > http://sourceforge.net/projects/cut
    >
    > It enables the TDD coding cycle, but I don't know where any source code
    > produced thusly is. What would such code prove?
    >
     
    goose, Aug 10, 2006
    #15
  16. Phlip

    goose Guest

    Phlip wrote:
    > Cers:
    >


    NOTE: this is off-topic here, perhaps it would be better
    to discuss this in comp.programming?

    > The majority of the world's legacy software is written in C.
    >
    > However, the market leader in new code is Java. The language is technically
    > inferior, and its success depends on two props. One of them is Sun's
    > marketing machine.
    >
    > The other is JUnit. This is the flagship system in a host of Free Software
    > tools that assist Test Driven Development. It leads related tools, like
    > CruiseControl and Fitnesse, which help Java shops rapidly ship stable
    > software, overcoming the language's technical problems.
    >
    > Put another way, the unique power of TDD to avoid debugging and streamline
    > development is partly responsible for Java's false appearance of success.


    I fail to see how TDD is unique in any benefit it may offer.

    > When you see Java's numbers, you see an effect of TDD.
    >
    > So it seems to me that people interested in maintaining majority of the
    > world's legacy codebases, and people interested in competing with Java via
    > technology (not marketing), would do well to learn TDD.


    You have not sufficiently convinced me.

    goose,
    fups to comp.programming
     
    goose, Aug 10, 2006
    #16
  17. Phlip wrote:
    > Cers:
    >
    > The majority of the world's legacy software is written in C.
    >
    > However, the market leader in new code is Java. The language is technically
    > inferior, and its success depends on two props. One of them is Sun's
    > marketing machine.
    >
    > The other is JUnit. This is the flagship system in a host of Free Software
    > tools that assist Test Driven Development. It leads related tools, like
    > CruiseControl and Fitnesse, which help Java shops rapidly ship stable
    > software, overcoming the language's technical problems.
    >
    > Put another way, the unique power of TDD to avoid debugging and streamline
    > development is partly responsible for Java's false appearance of success.
    > When you see Java's numbers, you see an effect of TDD.


    Does this imply that "TDD" is not used by C programmers,
    and that the way to do TDD is via general tools like JUnit ?
    That's at best some silly assumtions.

    Who's next after Phlip to tell us how to save the world btw ?
     
    =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=, Aug 10, 2006
    #17
  18. Phlip

    goose Guest

    Phlip wrote:

    <snipped>

    > I humbly submit the following, which I _did_ write, to make up for my
    > wooliness:
    >
    > http://flea.sourceforge.net/TDD_in_a_nut_shell.pdf
    >
    >


    Is there a plain text version of that? You /do/
    know that many of us on dialup are browsing the
    web using lynx, don't you?

    goose,
     
    goose, Aug 10, 2006
    #18
  19. Phlip

    Phlip Guest

    Phlip, Aug 10, 2006
    #19
  20. "Nils O. SelÄsdal" said:

    <snip>

    > Who's next after Phlip to tell us how to save the world btw ?


    My turn, I think.

    Now, folks, you're going to need two long pieces of string, a cereal packet,
    some sticky-backed plastic, a washing-up-liquid bottle, and a sharp pair of
    scissors...

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Aug 10, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. supercobra
    Replies:
    2
    Views:
    646
    Roedy Green
    Jan 10, 2006
  2. Christopher Benson-Manica

    Re: TDD doesn't suck

    Christopher Benson-Manica, Aug 10, 2006, in forum: Java
    Replies:
    1
    Views:
    392
    Keith Thompson
    Aug 10, 2006
  3. jean vacance
    Replies:
    9
    Views:
    161
    m4dc4p
    Jan 13, 2006
  4. Phlip
    Replies:
    6
    Views:
    155
    David Vallner
    Sep 10, 2006
  5. Tore Darell
    Replies:
    9
    Views:
    182
Loading...

Share This Page