Requesting critique of a C unit test environment - Page 4

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: Requesting critique of a C unit test environment

Quoted text here. Click to load it

"Unit" tests post-factum. Not "developer tests" that support generating
production code.

Before you create this prototype code, do you _never_ debug it?

When researching, I frequently write disposable code test-free. When I
convert it to production code, I write the tests first. The result is much
cleaner for two reasons: It's a rewrite - that's always cleaner - and it's
super-easy to refactor. Without debugging.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657 /
We've slightly trimmed the long signature. Click to see the full one.
Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it
I have found TDD to be a good tool for pointing me at a new algorithm.
It might just be the way a think, but given something I'd forgotten or
was too lazy to look up such as polynomial fitting, I start with a
simple flat line test, then a slope with two points, and so on until I
have a working general solution.  I've found a dozen or so tests are
required to pop out a working solution.  Given the working tests, the
algorithm can then be optimised.

--
Ian Collins.

Re: Requesting critique of a C unit test environment

Quoted text here. Click to load it

If you follow the exact refactoring rules, you'll remove all duplication
before adding the next line of code. I once tried that while generating an
algorithm to draw Roman Numerals, and I discovered that the outcome was
sensitive to one of my early refactors. The design I got sucked; it was
harder to code over time, not easier. I had to roll the entire process back
to that refactor, try it the other way, and _this_ time the correct
algorithm popped out.

TDD is a very good way to force a clean design to emerge, following simple
and known algorithms. But it's not a general-purpose algorithm generator.
Whoever discovers _that_ gets to go to the top of the food chain.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657 /
We've slightly trimmed the long signature. Click to see the full one.
Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it
There you go, the solution is to hold off all but the most trivial
refactoring until the end!

--
Ian Collins.

Re: Requesting critique of a C unit test environment

Quoted text here. Click to load it

That's a joke, guys.

When creating production code, not when researching, after passing a test,
try to simplify, and go in order from easy to hard refactors. Never try a
hard refactor first if there's an easy one available in the neighborhood.

The only exception is renaming things. Name them after their roles
stabilize!

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657 /
We've slightly trimmed the long signature. Click to see the full one.
Re: Requesting critique of a C unit test environment
Phlip wrote, On 02/09/07 01:36:
Quoted text here. Click to load it

Sometimes when code as been "hacked together" over time the only way to
get a clean design is to start from scratch and design it based on what
you have learned.

There is no one set of rules that is always correct.
--
Flash Gordon

Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it

Have you ever worked in a product R&D environment?  A lot of concepts
are taken for a test drive without ever seeing the light of day outside
the lab.  If the product does make it out the door, the original
concept proving/testing work is probably a very small portion of the
final product.  You want to spend a lot of time and effort producing
more formalized testing processes for something that has a very low
probability of ever being used in a production environment?

Re: Requesting critique of a C unit test environment

Quoted text here. Click to load it

Yes. I helped teach TDD and Python to polymaths who were into declaring
multi-dimensional arrays as void **.

Quoted text here. Click to load it

TDD is faster and easier than debugger-oriented programming.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657 /
We've slightly trimmed the long signature. Click to see the full one.
Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it

We call them spikes, or a proof of concept.  Once the concept has been
proven, the code is put to one side and re-written using TDD.

Even these spikes can often be produced faster with TDD, the time saved
not debugging justifies the more formal approach.

It's unfortunate that us C and C++ programmers are spoiled rotten with
decent debuggers.  Try developing something complex in an environment
without one and the benefits of TDD become clear.  I do a lot of PHP and
I have never bothered looking for a PHP debugger.

--
Ian Collins.

Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it

With TDD, if the branch isn't required to pass a test, it wont be there
at all.

--
Ian Collins.

Re: Requesting critique of a C unit test environment

Quoted text here. Click to load it

Put the test into FIT, and let the certifying agency change the input
variables and watch the output responses change.

Oh, are you going to say there are "certifying agencies" out there which
_don't_ expect literate acceptance tests to cover their requirements??

Sure explains KBR, huh? (-;

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657 /
We've slightly trimmed the long signature. Click to see the full one.
Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it
A certifying agency's stamp assures a Bhopal or Chernobyl plant manager
that it is safe to put your gadget in a safety application w.r.t.
acceptable safety risk according to a safety standard (ISO/IEC 61508 in
my case).
It verifies that
- you have an acceptable development process (from marketing
requirements to validation and everything in between, usually including
continuous improvement)
- you followed the process and can demonstrate it on every level.

It doesn't _run_ any tests for you; but it checks that you did so and
your tests were comprehensive and that you can show a documentation for it.
--
Ark

Re: Requesting critique of a C unit test environment
Quoted text here. Click to load it
Anyway, I posted a page, http://www.macroexpressions.com/maestra.html in
a hope that some people might find it useful.

-- Ark

Site Timeline