Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Argument starter - The roots of all evil
Message
From
31/08/2004 14:34:29
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00938079
Message ID:
00938141
Views:
28
Hi Terry,

You've hit on a subject that truly is a question of personal preference and nothing more. There is no "law" of programming that says LOOP/EXIT are bad... indeed they were added to most earlier languages to permit them to otherwise comply to "structured programming" practises where the "GO TO" and its derivatives were outlawed because of the spaghetti they invariably result in. That you have managed without them is a product of your programming style and I probably would find your code more tedious and troublesome to read, though Ihave no doubt that it executes accurately. For me, when I'm debugging, I prefer to have to go through as little code as possible to get to the root of the problem. Your method ensures that I have to read the whole thing every time.

Personally I believe there is great value to those constructs and I use them very frequently - whenever called for (per my programming 'style'). Some people are fond of not using those constructs but instead "adjust" the controlling value for the loop so that they exit next time through. This is definitely worse than explicitly coding an EXIT in my opinion.

The argument can also be made that there can be times where NOT re-working the code to make it more sensible under new circumstances is perfectly practical and the thing to do. If one is under extreme time pressures for some mod/fix then reworking the code necessitates a much larger test of the changes than does a few lines interjected for the condition.

Let me add my pet peeve to this thread... using the DO CASE construct to "do real work", meaning that a sequence of CASE statements all name functions that to their piece of some work and they are ALL EXPECTED TO EXECUTE for success of the processing. Now this situation, while 'sexy', *IS* something that should be outlawed!

cheers


>Hi all
>
>I would argue that the introduction of those evil commands - LOOP and EXIT - was just for lazy programmers who can't be bothered to restructure (indent etc.) their control loops when they suddenly discover another condition, or change necesaary to the loops. They are unnecessary and should never have been introduced. Personally I have managed NEVER to use them. When you have to debug someone else's labrythine, monolithic code, with 20 yard long do while loops, and short-circuiting loops and exits liberally scattered in the code, just to complicate it even further, like I have, then you'd get to hate them.
>
>I'd challenge anyone to present code where they're necessary.
>
>While I'm at it, don't get me started on multiple RETURN statements in a function ...
>
>:-)
>
>Terry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform