Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Argument starter - The roots of all evil
Message
De
02/09/2004 08:46:40
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
02/09/2004 08:13:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00938079
Message ID:
00938710
Vues:
50
Hi Terry

>
>Do while .T.
>  blah-blah-blah
>  If <condition>
>      LOOP
>  Endif
>  blah-blah-blah
>  SKIP
>  If EOF()
>      EXIT
>  Endif
>EndDo
>
>
>Without the evil twins the code would have been forced into something like:
>
>Do while not EOF()
>  blah-blah-blah
>  If not <condition
>      blah-blah-blah
>  Endif
>  SKIP
>EndDo
>
>
>With lack of training and/or insight into good structured practice, the existence of these commands can lead one into bad ways.

I think it is silly to call these the evil twins. It is the programmer that was evil ;) I also suggest that attempting to force anyone to code your way smacks of evil too. Having undergone a style-ectomy several times in my career (and a recent near miss), I can say it only reminds me how quickly power corrupts.

I also feel your first example is not a fair comparison to your second example. This is more like your second example:
>Do while not eof()
>  blah-blah-blah
>  If <condition>
>      LOOP
>  Endif
>  meat of the problem.
>  SKIP
>EndDo
To me the meat of the problem is significant. It is the real thing we're supposed to code. The rest is incidental. I find it totally acceptable to code these either way. However I prefer the one above. The meat of the work is clearly evident. The loop just precludes getting into the meat of the problem. I would also attempt to make the condition the negative and require the NOT. That would suggest I'm not getting to the meat unless the conditions are met. In effect, I've put a fuse ahead of a sensitive electronic circuit.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform