|
Balboos wrote: Oh, by the way - it's never to late to Send "W" a bag of pretzels, sit back, and hope.
The W stands for Honesty.
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton I gave up when I couldn't spell "egg". Justine Allen
|
|
|
|
|
Dave Sexton wrote: The W stands for Honesty.
Well - That must be why he spent so much time sitting Oval Office
(At least when he wasn't on vacation).
Then, too, I saw his last press conference - and I'm not so sure I believe the standing part, either.*
We really enter into a very philosophical domain:
Can an idiot (or even a mere moron) be deemed honest or dishonest?
* He considers his biggest error in Iraq to be the 'Mission Accomplished' sign.
Clearly, he's either an idiot . . . or a liar.
|
|
|
|
|
Nearing soapbox territory are we and I'm waiting to get blasted by an unhappy republican.
I have a friend who has put forward the notion that he is not an idiot but rather "acting the country fella" to mask a true agenda. I disagree and am more inclined to believe in idiocy.
Balboos wrote: Can an idiot (or even a mere moron) be deemed honest or dishonest?
Hmmm... interesting question. I would imagine that one would first need to establish if said moron is mentally capable of understanding what the terms honest and dishonest mean. If such capacity is there then the branding is fair.
Let's just hope the one coming in isn't as bad as the one going out. Frankly, I don't think you could get much worse. Wasn't the last democrat president Bill Clinton?
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton I gave up when I couldn't spell "egg". Justine Allen
|
|
|
|
|
|
As the poll suggests, there is a philosophy behind the simple task of using conditionals.
For one, I try to avoid too many if(a == null) return; statements, since it makes the code less readable.
I am wondering what others opinion is on this.
|
|
|
|
|
|
Nah, I mean constructions like this:
foreach(Item a in collection)
{
if(a.b == null)
break;
if(a.b is SomeOtherClass) {
if(a.b.c != "Something")
return;
}
}
A complex foreach loop with preferrably more than 20 lines of code inside of it. Aside from the fact that I would like to extract some methods from inside the loop. I think its quite nasty to see that many returns and breaks.
I totally understand the fact that people use if(a == null) return; statements at the start of the method. It's actually quite easy to see what the method expects. I do like theif(a == null) throw new ArgumentNullException("a"); construction better.
|
|
|
|
|
|
If do similar except I invert the condition
if(myObject != null)
{
}
else
{
}
That way I have logic focused at the top and null handling below it.
Either way works. Just prefer this one
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton I gave up when I couldn't spell "egg". Justine Allen
|
|
|
|
|
If the negative outcome is shorter, I put it at the top.
if(checkIfSomethingIsWrongHere)
{
return null;
}
else
{
}
If the error routine is in the same method and rather long, put it second
if(haveWeSucceeded)
{
}
else
{
}
Cheers,
Vıkram.
I don't suffer from insanity, I enjoy every moment of it.
|
|
|
|
|
If Not(isMisspelled("seamingly") then
quit
else
correctSpelling("seamingly", "seemingly")
end if
JackMcG
|
|
|
|
|
JackMcG wrote: If Not(isMisspelled("seamingly") then
Syntax error!
Gary
|
|
|
|
|
The rule of thumb I usually use is to place the most frequently encountered condition first. A professor in college taught me this - it can actually make the program more efficient since that reduces the number of conditions that need to be checked. Granted, if the statement only has a single IF with an unconditioned ELSE, this doesn't make any difference, but if you are using an ELSEIF or CASE construct, it can make a huge difference.
Then again, I went to college way back when saving a few CPU cycles actually mattered...
|
|
|
|
|
Pretty much agree with that thinking for CASE constructs of putting the most likely. Although I do break it fairly often too. For instance, I usually assume that someone else will get their hands dirty in my code sometime on the future, so I may use a more 'obvious' ordering to the conditions for the benefit of any poor sucker that comes behind.
However, when it comes to XSLT choose blocks I've often found it necessary to put the weird edge cases first and then proceed to the more commonly expected ones later. In other words filter out the strange stuff that requires special handling before you get to what you're really after. Unfortunately this is more CPU intensive, but then again that's XSLT.
I just love Koalas - they go great with Bacon.
|
|
|
|
|
In cases where you cannot tell which condition will be taken more often I put the smaller clause first in the hopes that a false prediction won't necessarily cause as much cache pollution.
|
|
|
|
|
That is what I do. I wonder if this is what most of 69% "depends on the situation" category do? I see the need to re do this poll..
John
|
|
|
|
|
Ed Leighton-Dick wrote: Then again, I went to college way back when saving a few CPU cycles actually mattered...
They still matter IMO. They're so cute when all fluffy and running about, we must save them!
|
|
|
|
|
No ifs and buts in my code
|
|
|
|
|
this.FullOfFoo = this.Nationality == "Serbian";
//
|
|
|
|
|
haug,serbian brother !
|
|
|
|
|
Srbija do CodeProject-a... :P
|
|
|
|
|
Stupid poll.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Interestingly, the votes go to "depends on the situation", rather than random.
This means that most of us do have a strong preference, given a specific condition to test.
Or that most of us didn't read beyond the 3rd option.
|
|
|
|
|
peterchen wrote: Or that most of us didn't read beyond the 3rd option
I was also wondering that!
|
|
|
|
|
I agree on 2ed one that most of them didn't read after 3ed option
Whatever you do will be insignificant, but it is very important that you do it
|
|
|
|