Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To iif or not to iif = .t.
Message
De
01/06/2001 14:56:23
 
 
À
01/06/2001 09:18:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00513276
Message ID:
00513978
Vues:
13
>Just out of interest, how would you code the following, especially with regard to an if without an else being a bug/bad design.
>
>
>while .t.
>  < some code >
>
>  if < condition >
>    exit
>  endif
>
>  < some other code >
>enddo
>
>
>the best I get is
>
>
< ensure condition true >
while < condition >
  < some code >

  if < condition >
    <b>* No further processing required</b>
  else
    < some other code >
  endif
enddo
>
Note the explicitly added comment. This tells the reader that the alternative branch was considered, and provides a pre-built entry point if and when the business logic is modified in the future.

In my maintenance programming experience, failure to consider the alternate branch causes some of the most subtle and hard-to-find bugs.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform