Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Argument starter - The roots of all evil
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00938079
Message ID:
00940574
Vues:
25
I like a clean look in programs but there are times when troubleshooting problems or locating where something specific occurs in a program is time consuming and frustrating when you have something like the below which starts to resemble the 'GOTO' command:
*some processing

Do program1  && program1 calls program9 which calls function2, function9,etc
Do program2  && program2 calls another procedure and function, etc.
Do program3  && etc

*some more processing

Do program4
Do program5
Do program6

*etc
It's ideal to have commonly used functions in their own prgs or a procedure file but in some cases I have seen every single function and procedure in a separate prg and not only were there literally hundreds of prgs in the project but I was forever opening up separate prgs locating stuff...


>>>>SNIP
>>>>>
>>>>>John,
>>>>>
>>>>>First of all, I don't consider myself an "expert". Rather I simply believe that if there's a reason that is quantifiable for breaking "the rules", then by all means do so.
>>>>>
>>>>>OTOH, I think that, in most cases, following the rules demonstrates a long term benefit.
>>>>>
>>>>>The thing is, in order to follow the rules and to know when to break them requires that the rules, and their purpose, are understood in the first place.
>>>>
>>>>George,
>>>>
>>>>Where is this "rule" that says EXIT/LOOP are WRONG?
>>>>EXIT/LOOP, for instance, do NOT qualify for the "single exit point" rule because they are not exiting the module but simply exiting (or redoing) some looping construct.
>>>>
>>>Jim,
>>>
>>>IMV, they're the xBase equivalent of GOTO. That's me. I've never found a reason to use them.
>>
>>George,
>>
>>OK, that's your view.
>>But for other readers of the thread I want to clarify something...
>>
>>EXIT/LOOP are in no way the equivalent of a GOTO, specifically in the way that structured programming specified the elimination of GOTO. In fact you'll find that EXIT/LOOP were added to languages to permit them to comply with structured programming specifications with simplification of code in the process.
>>Structured programming prohibits GOing (JUMPing, BRANCHing, etc) from one 'module' to another EXPLICITLY, which is what GOTO and its derivatives (can) do (making for fine spaghetti but most difficult code reading/debugging).
>>EXIT/LOOP, on the other hand, provide the ability to skip some code WITHIN a looping construct, EXIT going immediately to the next line after the looping construct and LOOP letting you resume the loop immmediately without executing code below itself. NOTE: Neither LOOP nor EXIT have any argument or parameter or operand so they can ONLY GO TO ONE DESTINATION EACH and THAT DESTINATION IS ALWAYS within the same module. Of course GO TO, JUMP, BRANCH etc ALL have to have an argument or parameter or operand (where to go) and such specification CAN GO ANYWHERE - within the same module or to another module.
>>
>Jim,
>
>I misspoke when I said I never use EXIT. In certain situations, when there is no other choice, I do. For example, when searching a collection for a particular value when there is no other choice.
>
>Now having said that, I should point out that even UCSD Pascal supports a GOTO statement. Does it mean it should be used regardlss of the evironment or circumstances. No! LOOP, in my mind, is totally useless unless extenuating circumstances (namely processing time) require it. Even though Tamar has indicated that there's an order of magnitutde difference between using a FOR...ENDFOR construct over a DO WHILE, I don't necessarily believe that it would apply in all cases. While her remarks were directed towards VFP 7.0 and above, in VFP 6.0 it took in excess of 10,000,000 iterations before more than 1/10th of a second was realized.
>
>In my mind, both LOOP and EXIT change the flow of control. If they are not used when the situation warrents, both make the code harder to read and understand.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform