Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One exit per procedure/function/codeblock to what purpos
Message
From
10/10/2003 09:34:08
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
09/10/2003 17:23:36
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00835552
Message ID:
00837364
Views:
42
Hi Al

I think we'd all do better to remove style from such discussions. I also think we'd do better to approach this with the belief that someone certainly has a better way to do things.

Further, let's pretend we're electronic engineers. That way if we do something weird, the circuit may work, or it may burn up after a while, or the relay may click too slowly.

It used to be we'd try to be efficient, now we're letting faster computers make us lazy. We cannot know what machine the user may have. We can be certain our code is the best it can be. Is that not the very purpose of the UT?

Just remember everytime you use a commercial Piece Of Software ;) and find it slow, it's because someone got lazy.

>>You're not saying that
FOR x = 1 TO 10
>>    ...some code
>>    x = 11
>>    ...some more code
>>NEXT x
>>is better than
FOR x = 1 TO 10
>>    ...some code
>>    EXIT
>>    ...some more code
>>NEXT x
are you?
>
>No, they're both bad ;-)
llDone = .F.
>x = 1
>
>DO WHILE x < 11 AND NOT llDone
>  ...some code
>  * Set llDone appropriately
>
>  x = x + 1
>
>ENDDO
I'm guessing you were kidding. Would a discussion of the reasons why this example might be used as a joke be OK?

How about a list of conditions that should support a standard. Clarity/maintainable, efficiency,

Clarity: I believe it is slightly confusing, because "< 11" isn't as clear as "= 10". FOR X = 1 TO 10 clearly indicates the range of the loop.

Efficiency: The m.llDone variable requires extra code to create and update.
The use of the do while...enddo versus the for...endfor involves an extra line x = m.x + 1. x would have to be declared as 1 before the loop.

m.llDone clearly indicates the routine is done. It doesn't indicate the routine abended. Adding m.llAbended may be valid if it is included for the same reason as m.llDone. If on the other hand we can say it is nonsense to add m.llAbended, it may be argued we should not include m.llDone either.

IMO, Jim's second example is best, because it has no extraneous code to reduce clarity or efficiency.

One other point. We're proposing standards, but how/where can we write them up. The wiki is good, since it allows edits.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform