Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which Should I Use IF/ENDIF or IIF
Message
 
To
17/06/2002 12:12:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00668532
Message ID:
00669734
Views:
13
Tracy;

I am very open as to how I solve a programming program. However I have one rule which I have not disobeyed - yet! Never modify or change code that anyone wrote if it works! That goes for the code of others as well as my own! There is always a better way to do anything in programming and some people have "pet" ways of implementing solutions. If everyone spent time “correcting each others code” little would get accomplished.

I may not agree with the code someone wrote but if it works – do not “fix it”! I can see ten programmers working on the same code over a period of time. If each one put in his/her 2 cents worth to “do it right” it would be such a waste of time.

When I am asked to make changes to existing code I always code out (save) and comment what was done, why, when and by whom. My new code goes at the top of the previous code. I do this even when using Visual Source Safe. Some habits are hard to break. :)

Tom

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

Click here to load this message in the networking platform