Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
From
01/06/2001 20:49:31
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00514098
Views:
24
>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.

Point taken. My personal practice is that if a condition has more than two ANDs or ORs I replace it with a function call.

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

I'd consider "at all costs" a bit severe, especially if it means using EXIT, LOOP, etc. This is clearly a matter of style, but the arguments being made are interesting.

>
>>>
>>< 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
Reply
Map
View

Click here to load this message in the networking platform