Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WITH ENDWITH question
Message
From
22/08/2003 22:19:11
 
 
To
22/08/2003 20:34:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00822119
Message ID:
00822831
Views:
13
SNIp
>
>I think we're going to have to agree to disagree on that one. I'm not going to pretend that the idea of only 1 exit point is more readable, but I certainly have to disagree that it is less so. If you don't read all the code, then how on earth do you know what the code is about? Are you suggesting that if there are 5 exit points, you only have to read as far as the first one? Regardless of the number of exit points, the only way to understand the routine is to read and decipher the whole thing.

Actually, I agree when it come to "learning what the code does". It **IS** six of one... But when it comes to debugging exiting whenever appropriate wins hands-down. As soon as I see the return I know that I'm finished with that routine and can start into the next.

SNIP
>
>You're going to hate this, but yes - EXIT does bother me. For instance, when I write a for routine that might exit early - I do this (for example):
>
>
For lnCount = 1 to Alen(laSomeArray)
>   If lcSomeVar $ laSomeArray[lnCount]
>      lnMark = lnCount
>      lnCount = Alen(laSomeArray)
>   Endif
>EndFor
>
>I know it's not more readable than using EXIT - perhaps even less readable, but...
>
>Well? Was I right? You hate it, don't you. <s>

Hate, no, because you can do whatever you damn well please! But I do think it requires more attention to catch the coded forced exit whereas EXIT is pretty damned clear and not likely to be overlooked.

>
>Like I said, this is just my way. It feels right to me, but diversity is what makes the world go round.

Agreed... and far more interesting too.

cheers



>
>Cheers
>>
>>PS A music teacher of mine told me that I'd only ever be a garbageman because I wouldn't sing in front of the class.

>
>I sing in my garden as a sort of pest control.
>
>Alan
>
>>>>Methinks you missed an important point...
>>>>
>>>>Let the subroutine have, say 40 more lines of code and let there be 2 more (keeping it low) additional IF statements at the 'base' level. With "only a single return" (at the end of the code) in force, where has the readability been improved by enforcing that rule? Where has any time - THE huge argument for code readability - been saved in reading that code while debugging something?... especially if it turns out that this routine is not implicated in the bug at hand.
>>>>
>>>>
>>>>>It seems more readable this way:
>>>>>
>>>>>with this
>>>>>if !.Something
>>>>>   llReturnFlag=.f.
>>>>>else
>>>>>   llReturnFlag=.t.
>>>>>endif
>>>>>endwith
>>>>>return llReturnFlag
>>>>>
>>>>>My suspicion is that short-cutting an encapsulation might bait a C5.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform