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

I was hoping to get a heated discussion going! :-)

> ... and I probably would find your code more tedious and troublesome to read

MY code, Sir, reads like Shelley or Keates!!! :-)

>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.

This is one of the points I'm making. You're going thro' a do loop, here's the start and here's the end (20 screen loads down), so here's where you get off - Oh but remember you can jump out of it here, loop back to the start here ... and there ... and oh here's ANOTHER exit, oh I see this code I was concentrating on doesn't get done because of another loop, etc. etc. I don't mind so much the odd case where there's a loop to find something like:
For I = 1 to lnNoUsers
  If laUser( I) = "Current"
      EXIT
  EndIf
EndFor
to avoid a do while, with incrementing I statement, but a huge loop with cases, sub-loops, for - nexts, loops within loops, etc. - each potentially having its own LOOP and/or EXIT in it is a nightmare! And I would suggest it obfuscates the flow of the code.

>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.

No, I would say, except in my above example, this is a cop out, and tantamount to multiple RETURN statements in a function ( which evolve either for similar reasons as my original beef or because people don't actually know it's bad practice).

>
>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.

In these cases I would consider letting the programmer off :-). But, if you could see the code I have to debug, with loops and exits thrown in for these very reasons, as it has eveloved, you might change your view.
>
>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!

Don't quite follow the above.

Thanks for the feedback.

Cheers

Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Reply
Map
View

Click here to load this message in the networking platform