Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
 
 
To
01/06/2001 14:56:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00514070
Views:
21
Al,

The problem with not using EXIT for your code is you have written the condition code twice. If that is a complex expression there is a significant chance that the code will be editted in one place and not the other, yielding a hard to find bug.

IMHO, I prefer simplicity in code and early exits/loops are sometimes the best choice. Duplicated code should be avoided at all costs.

>>
>< 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.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform