Are programmers negative people
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
Depends on the code. I prefer the first branch to be the expected one, such as:
if(FileIsOK())
{
}
else
{
}but
if(!FileIsNotOK())
{
}
else
{
}Of course I wouldn't write FileIsNotOK in the first place because it's not intuitive, but you get the idea with conditions. Normally you would expect file to be OK most of the time, so most commonly expected case should go first.
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
My coffee cup is always empty, never full.
Todd Smith
-
My coffee cup is always empty, never full.
Todd Smith
Then your coffee dispenser is to far away. :-D
Artificial Intelligence is no match for Natural Stupidity
No one can understand the truth until he drinks of coffee's frothy goodness. ~Sheik Abd-al-Kadir
I can't always be wrong ... or can I? -
This reminds me of a joke. An optimist says the glass is half full, pessimist says glass is half empty, programmer says the glass is twice as big as it needs to be.
JazzJackRabbit wrote:
An optimist says the glass is half full, pessimist says glass is half empty, programmer says the glass is twice as big as it needs to be.
Heard that one before. It's a good one :)
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
That's just natural. In nature anything unique can be more quickly identified by what it isn't. You don't identify something unique by leaping to the right conclusion immediately... well, some try and are often wrong. Programming follows this same pattern because most conditionals are looking for an exception to an expectation of what will be a normal value because most are used to handle something unique.
"It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson
-
This reminds me of a joke. An optimist says the glass is half full, pessimist says glass is half empty, programmer says the glass is twice as big as it needs to be.
Real men don't drink from a glass. They drink from a canteen, a broken bottle, a running stream, or a hubcap, all the while looking for a target of opportunity.
"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 -
This reminds me of a joke. An optimist says the glass is half full, pessimist says glass is half empty, programmer says the glass is twice as big as it needs to be.
Hahahaha. Is that public domain, or do I credit you when I use it on my web site?
Q: What is the difference between a pigeon and a merchant banker? A: A pigeon can still put a deposit on a Ferrari.
-
Real men don't drink from a glass. They drink from a canteen, a broken bottle, a running stream, or a hubcap, all the while looking for a target of opportunity.
"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/2001John Simmons / outlaw programmer wrote:
Real men don't drink from a glass.
Yep. Only drink from a mug around here :rolleyes:
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
I don't not find that non-positive logic tests are not less complex to understand.
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
I see this most often when working with code written by die-hard "only one return per function" coders. Tests for NULL / invalid values, right before the huge block containing all of the code in the function. It annoys me. A lot. I'm usually quite happy to re-write them in a less negative fashion...
----
You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.
-
Hahahaha. Is that public domain, or do I credit you when I use it on my web site?
Q: What is the difference between a pigeon and a merchant banker? A: A pigeon can still put a deposit on a Ferrari.
-
This reminds me of a joke. An optimist says the glass is half full, pessimist says glass is half empty, programmer says the glass is twice as big as it needs to be.
I seem to recall a Dilbert version of that joke where he says something like "I have a redundant backup over here" and points to another half empty/full glass.
Sunrise Wallpaper Project | The StartPage Randomizer | The Windows Cheerleader
-
I don't not find that non-positive logic tests are not less complex to understand.
:laugh: Is that yes, or no?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
-
I seem to recall a Dilbert version of that joke where he says something like "I have a redundant backup over here" and points to another half empty/full glass.
Sunrise Wallpaper Project | The StartPage Randomizer | The Windows Cheerleader
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
Don't think it matters too much, most of mine are if(x!=null) type blocks as I only want to do something to an object if its actually set, I kinda miss c/c++ where you could just do if(x) guess maybe it was more prone to errors though say when you get pulled into a meeting halfway through typing a statement out.
-
i think the real question is... is the stack half empty...or half full...
----------------------------------------------------------- "When I first saw it, I just thought that you really, really enjoyed programming in java." - Leslie Sanford
push eax problem solved.
-
I was just reading through some code, looking for the cause of an undocumented feature, and it occurred to me that something like 70% of my conditional statements are in the negative. e.g. if (x != y), or while (!p). Is this the same for you guys/gals, and is it a bad thing?
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.
No :laugh:
Matt Newby President, Matt Newby Enterprises, Inc. matt@mattnewby.com