Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NOT vs ELSE
Message
 
À
13/11/1998 09:50:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00157136
Message ID:
00157387
Vues:
17
>I'll toss my $0.02 (US) into the ring here. Back in the dim and distant past, when real programmers used punch cards, even before Ashton met Tate < G > I learned to program in COBOL. I was taught to evaluate the likelihood of results of IF...Else.. and CASE statements so that the most likely response was the first condition tested for. Then the others followed in descending order of likelihood. I was also taught to use NOT instead of else because it offered easier readability and also clarified your logic to whoever got to maintain your code.
>
>There is an implied difference between
>i. "IF (A) then whatever ELSE (B) whatever END" and
>ii. "IF NOT (A) then whatever...."
>
>The first example implies that A is more likely to happen than B. The second example implies that A is not likely to happen. The expectation of whoever is reading your code (including you if it was long enough ago) is that in the first example that A is the norm and B is the exception. If this is not the case then whoever gets to test the code will be suprised.
>
>This is basic logic flow and applies to all languages. It even applies to sets of written or verbal instructions we give to people. Listen to your selv next time you explain something to someone...
>
Hi Jen,

Earlier in the thread I said that I'd come down on the side of readability over some miniscule performance gain. I think you summed up the underlying possibilities quite nicely. :-)

Small personal segue here. First, good to see you back. Second, I miss the previous signature.:-)
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform