Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
From
01/06/2001 14:56:23
 
 
To
01/06/2001 09:18:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00513978
Views:
12
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform