Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which Should I Use IF/ENDIF or IIF
Message
From
17/06/2002 12:12:56
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00668532
Message ID:
00669285
Views:
26
This discussion reminds me of a personal experience I had. I tended to code using IIF instead of IF/ENDIF when possible under the assumption that 1) it will run faster and 2) I can use the IIF statement easy in a report. I always use documentation to explain the conditions above the statement.

However, when other programmers were making mods to one of the apps I developed, they came across my IIF statements and rewrote them ALL using IF/ENDIF because EVEN THOUGH THEY WORKED FLAWLESSLY, the other programmers could not understand the conditions without breaking it down into IF/ENDIF statements. They were afraid to modify the statement in anyway if the condition needed to change for whatever reason because they feared it would no longer 'work.'

I now code whenever possible using IF/ENDIF instead of IIF simply because sometimes it is better to make the code more easily understood by other programmers than to make it a little faster.

I guess that's teamwork :o)
Tracy

>Sergey;
>
>The greatest “joy” of all working with conditional statements is imbedded IIF’s! That is multiple IIF statements within each other. Not a good thought for a Friday. :)
>
>Tom
>
>>>Sergey;
>>>
>>>I think all code should be contained on one line - it runs faster. My goal is to write a complete application on one row. Think of the speed! :)

>>
>>At some point, under influence of the C book I read at that time, I wrote code like that
llOk = Func1() And func(2) And (Func3) ... and so on
Not very readable but compact. :)
>>
>>>In real life I will normally use structured code for readability and sometimes IIF statements when needed. Some IIF statements can be complex to understand.
>>
>>The same here. If I've a choice between IIF() and IF I would use IIF() only if condition is simple and there could be multiple separate squential statements with IIF()'s. In this case code would be more readable with IIF() because of it compactness.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform