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,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: adam@irvine.com Subject: Re: Software landmines (loops) Date: 1998/09/08 Message-ID: <6t4dge$t8u$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 389186088 References: <6rf59b$2ud$1@nnrp1.dejanews.com> <6rfra4$rul$1@nnrp1.dejanews.com> <35DBDD24.D003404D@calfp.co.uk> <6sbuod$fra$1@hirame.wwa.com> <904556531.666222@miso.it.uq.edu.au> <6sgror$je8$3@news.indigo.ie> <6sh3qn$9p2$1@hirame.wwa.com> <6simjo$jnh$1@hirame.wwa.com> <35eeea9b.2174586@news.erols.com> <6sjj7n$3rr$1@hirame.wwa.com> <35f055a5.1431187@news.erols.com> <6sjnlu$83l$1@hirame.wwa.com> <6skfs7$2s6$1@hirame.wwa.com> <35F252DD.5187538@earthlink.net> X-Http-Proxy: 1.0 x5.dejanews.com:80 (Squid/1.1.22) for client 192.160.8.44 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Tue Sep 08 23:10:06 1998 GMT Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada X-Http-User-Agent: Mozilla/3.0 (X11; I; Linux 2.0.18 i586) Date: 1998-09-08T00:00:00+00:00 List-Id: In article <35F252DD.5187538@earthlink.net>, Charles Hixson wrote: > I suppose that it is possible to write spaghetti code without using > goto's, I've never tried. Sigh . . . does anyone *try* to write spaghetti code? The thing is, someone who's inexperienced and hasn't read enough code to know whether code is readable or not, is certainly capable of writing unreadable, convoluted code without using GOTO. I can't say whether I've written any such code (because if I did, I would have been too inexperienced to recognize it...), but I do know that I've *seen* plenty of convoluted code written by people brought up in the "GOTO is evil" religion. Maybe it shouldn't be called "spaghetti code" since the control doesn't wind up over itself; maybe "rotini code" is more appropriate since although the different parts aren't entangled, they're all completely twisted within themselves. But if the goal is to write code that doesn't give a migraine to someone who tries to understand it, rather than merely to identify which form of pasta is appropriate to a particular piece of code, then Joe is absolutely right that it's possible to write code without GOTO that is just as twisted as the unstructured, GOTO-loaded code that older programmers used to write. > I do know that with goto's INSTEAD OF while, > until, elsif, begin...end, etc. it was very difficult NOT to write > spaghetti code How could it be that difficult? I found it quite easy. I used to work in COBOL in the late 1970's, before COBOL had decent control structures, and I learned that in many cases, it seemed better to *avoid* PERFORM .. WHILE, since it took important chunks of code out-of-line and made it more difficult for readers to understand. So, instead of PERFORM..WHILE, I often wrote code like START-OF-LOOP. IF some-condition THEN GOTO LOOP-END. BODY-OF-LOOP. ... do whatever GOTO START-OF-LOOP. LOOP-END. (Usually with more appropriate paragraph names.) This is well-structured, and not difficult to write, and should be easy enough to understand for anyone who has a clue what WHILE loops do in the first place. So I can't imagine what would merit calling this "spaghetti code", unless you belong to the "GOTO-Is-Evil" religion (St. Edsger's Church) and believe that spaghettiness can be determined by counting the number of GOTO's. > and since there was originally the theory said that the > best code economized on the number of CPU cycles, rather than optimized > intelligibility, there was every reason TO write code that took > short-cuts. Ummm, I don't see how this has anything to do with Joe's point. Sure, if you think GOTO's are fine *AND* one of your prime motivations is to eliminate as many cycles as possible, you're more likely to write unintelligible code; but Joe is only questioning the assumption about GOTO's, and is saying nothing whatsoever about nanosecond-squeezing code. -- Adam -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum