TDD doesn't suck

P

Phlip

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.
 
R

Richard Heathfield

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.
 
P

Phlip

Richard said:
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.
 
P

Phlip

Richard said:
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?
 
C

Christopher Benson-Manica

Richard Heathfield said:
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.
...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. said:
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

Christopher Benson-Manica

(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

Ian Collins

Christopher said:
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.
 
R

Richard Heathfield

Phlip said:


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.
 
K

Keith Thompson

Christopher Benson-Manica said:
(WRT TDD in Java)


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.
 
C

Chris Dollin

Richard said:
Phlip said:


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 ...
...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.
 
C

Christopher Benson-Manica

In comp.lang.c Keith Thompson said:
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.
 
D

Dik T. Winter

> Phlip said:
>

>
> 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.
 
P

Phlip

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. ;-)
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 said:
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 said:
...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
 
G

goose

Phlip said:
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.
 
G

goose

Phlip said:

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
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Phlip said:
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 ?
 
R

Richard Heathfield

"Nils O. Selåsdal" said:

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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top