On Saturday, March 10, 2012 6:29:53 PM UTC, Kaz Kylheku wrote:
> On 2012-03-10, nick_keighley wrote:
> > On Friday, March 9, 2012 11:56:22 PM UTC, Ian Collins wrote:
> >> On 03/10/12 12:43 PM, Don Y
> >> > But, I can't see a way to handle this sort of testing on
> >> > functions that manipulate *pointers* to objects -- without
> >> > adding a fair bit of code to the scaffolding that, itself,
> >> > represents a testing issue! (i.e., does the scaffolding
> >> > have any bugs that result in false positives or negatives??)
> >
> > I think you have to draw the line somewhere. Testing test code
> > leads you into a infinite regression.
>
> That is moot anyway because the point of a /regression/ test suite isn't to
> find bugs or validate functionality. It's simply to validate that the
> behavior hasn't changed between revisions (including buggy behavior!)
ah. ok. But the first time you run the test it /is/ supposed to be part of your validation.
> Thus an imperfect regression test suite can still find a regression.
<snip>
> >> As a general point, it a lot easier and more satisfying for the
> >> programmer to write the tests before the code under test.
> >
> > I know this is the received wisdom in certain circles but I have trouble
>
> This is just "top down design" under new verbiage.
ah, I thought it was nonsense the first time round! I remember reading a book where a guy constructed an entire program top. Jolly cleaver I thought but how does he know how to write exectly the right procedure at each step. To make no mistakes, no false steps. I suspected then- and more than suspect now! that he didn't actually write the program the way he claimed he'd written it.
> Some programmers like to
> write the low-level functions and then express the higher level ones in terms
> of the language of these lower level functions. Other programmers are able to
> write the top that they want first and fill in the bottom.
I do a bit of both. I like to think of the "outside" of the program. Then go into a tool building phase. These are the sort of things I'll need to getthe outside behaviour. The bolt things together, testing as I go. If its very complex then there may be many layers. Oh and these days OO seems to the natural way to do things even if C is the implementaion language. Functional programs I'm still struggling with.
> > writing the test before I've at least specified the function's
> > prototype. And certain tests aren't writable until you've seen the
> > function's internals. For instance certain floating point
> > calculations may have divide by zero possibilities which you only
> > know about once you've seen the code.
>
> There are obvious limitations to "test first" or "top down".
my favourite example was a stream of bytes to hold messages. This could be read from, usually forwards but occaisonally backwards. Internally the stream was a singly linked list of fixed sized blocks. 32 bytes in size if I remeber correctly. This was hurried into "integration test" (put everyting ina big bag and shake it) without any module testing. In the field it failed.. That's right when it tried to reverse over a block boundary.
> For instance, imagine it is 1969. Let's write a test case for the
> awk language!
> Okay, let's see now: invent C, Unix, Yacc, the Bourne shell, etc.
> Finally, awk arrives, and and we can execute our test case!
>
> Bottom up is the way things really progress; top down is a small-scale, local
> aberration.
I used to design top down but implement bottom up. Writing mock functions so I can implement and test top down just seems tedious.
top down used to lead to some odd programs. One program I saw seemed to follow a rule of three. The top called three functions each in turn called three more. Eventually he got bored and a big lump of code down in the bowels suddenly did all the work.
|