From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,f66d11aeda114c52 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,f66d11aeda114c52 X-Google-Attributes: gid103376,public From: Paul Johnson Subject: Re: Building blocks (Was: Design By Contract) Date: 1997/10/15 Message-ID: <5w3FnzA6KRR0Iwt+@treetop.demon.co.uk>#1/1 X-Deja-AN: 281056103 References: <34316EC3.5B62@dynamite.com.au> <199710011402.QAA02444@basement.replay.com> <3432788C.E35@uk.ibm.com> Distribution: world X-NNTP-Posting-Host: treetop.demon.co.uk [158.152.55.135] Organization: home Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-10-15T00:00:00+00:00 List-Id: In article , Matthew Heaney writes >In article , Paul Johnson > wrote: >>I know that this was an aside, but it still puzzles me. Surely it will >>be wrong if the file is empty: there will be no record to read. The >>correct version (in Eiffel) would be >> >> from file.open("foo") until file.eof loop >> thing.accept (file.record) >> end -- loop [...] >I think the original example, though, was this: read some numbers from the >user interactively, process each one at a time, and stop processing when >the user enters a zero. In Ada, it would be [...] >A while loop is more complex and error prone solution for this type of >problem. Soloway showed that there was a statistically significant >difference between two populations, one using a test-at-the-top, and the >other using a test-in-the-middle, with the latter group having fewer >errors. The reference is: > >Coginitive Strategies and Looping Constructs: An Empirical Study >Elliot Soloway et al >CACM, Vol. 26, No. 11, Nov 83, p. 853 - 860 [Examples of when you want to do this in real life deleted.] Hmm. Interesting. I agree that the repeated read (or whatever instruction) before the loop and at the end is a bad idea. Quite apart from the Soloway experiment, it is duplicating code. OTOH I wonder if the situation might be reversed in real life situations with deeply nested structures. I'm rather dubious of small, neat coding experiments such as Soloway's. While they are the best handle we have on the facts, I worry that in an attempt to come up with a controllable, repeatable, and above all feasible experiment, they abstract out too much complexity. After all, it is complexity that makes programming difficult. I recall the great AT&T telephone crash in the late 80s (87?). It was caused by a bug where a programmer had mistaken the scope of a "break" instruction, and hence miscalculated the target of the resulting jump. Now thats not a statistical experiment, but its a worrying data point. I wonder what would happen if Soloway's experiment were repeated with more complex problems involving nested loops. (I haven't actually read the paper, but I'll see if our library has it tomorrow). Paul. --------------------------------+--------------------------------- Paul Johnson | You are lost in a maze of twisty Email: Paul@treetop.demon.co.uk | little standards, all different. paul.johnson@gecm.com |