|
Makes sense, the value could also be FileNotFound[^]
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If the only thing I am looking for is the false condition then I don't create an empty block. I do "not" the thing. If I change my mind later I do refactor it correctly.
This would mean I should have voted for "it depends", but this scenario happens very rarely.
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chineese Proverb]
Jonathan C Dickinson (C# Software Engineer)
|
|
|
|
|
It's mind boggling that those kind of surveys do get created. Even more so, that I'm actually voting for this. It's just plain disturbing that I'm not the only one
|
|
|
|
|
code project should conduct survay like this. It will improve developer knowledge.
|
|
|
|
|
I was sure there would have been a Chuck Norris joke in here by now...
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Chuck Norris is sooo yesterday. Long live Jon-Skeet. Jon Skeet's code doesn't follow a coding convention. It is the coding convention.
Jon Skeet Facts[^]
|
|
|
|
|
<br />
if expression is true then action_1<br />
else action_2<br />
Here is Chuck Norris' version:
<br />
set expression to true; action_1; <br />
set expression to false; action_2; <br />
modified on Friday, January 23, 2009 11:50 AM
|
|
|
|
|
My conditionals test themselves, dammit.
|
|
|
|
|
i do it like this:
typedef BOOL (CALLBACK* ConditionFn)();
BOOL CALLBACK falseFn()
{
...
}
BOOL CALLBACK trueFn()
{
...
}
ConditionFn doIt[2] = {falseFn, trueFn};
doIt[testCondition]();
|
|
|
|
|
You rock. I'm pretty sure that's what CListCtrl does as well.
|
|
|
|
|
|
Is TRUE always equal to 1?
|
|
|
|
|
it's C, so yeah, probably.
|
|
|
|
|
It depends.
I first evaluate the condition which will probably hits more. And then second most condition to hit and more and more ...
if ( probablity to hit most of the time is placed here )
;
else if (probablity to hit a little less than the first one )
And if the condiation is more than four i use to use switch statment.
Ashar
|
|
|
|
|
That's exactly what I try to do most of the time.
|
|
|
|
|
I agree with this !
Wisdom is often meant as the ability and desire to make choices that can gain approval in a long-term examination by many people.
|
|
|
|
|
The compiler will optimize an If/Then/Else in a manner that makes it impossible to accurately predict which is more efficiently executed. See Code Complete 2nd edition for lots and lots of examples of this. Additionally, since a conditional evaluation is short-circuited, the construction of the conditional itself probably has significantly more impact on efficiency.
Thus, my view is that the conditional should be coded in a manner that optimizes clarity, readability, and maintainability of the code.
Tom
|
|
|
|
|
Compiler optimization of the code is related to static code analysis. While probabilty to hit (most of time); which block of code; programmer can better predict.
|
|
|
|
|
This is exactly what I do as well.
|
|
|
|
|
After all MS has a tool that lets you click, drag, and not need to think about such trivalities.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
I tend to like to code the if so that it diverts the code into a side condition and allows the flow straight through for the most common condition.
|
|
|
|
|
I agree, especially for early exiting a function. It reduces the levels of indentation.
|
|
|
|
|
We Don't Need No Stinkin' "THEN".
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
|
Personally, I try to avoid putting statements in my conditionals...
if (expression is true) then...
if (expression is false) then...
are both acceptable though.
|
|
|
|