- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
C# does support null for value types. It's called nullable types and you define 'm like bool? name = null, or something.
Admin
Clearly, the designer's brain is very null.
Admin
This reminds me of a manager I had who would send out status reports of our tasks from time to time. First he would flag them with priorities of "H", "M", and "L", for High, Medium, and Low. But after a couple of months, he introduced the priorities "HH", "HM", "ML", and "LL". It was explained that HH was "Very High", "HM" was "High-to-Medium"... you get the idea. Then he started using special color coding to denote which tasks were "blockers", and bolding which tasks where "critical bug fixes", and he introduced "HHH" tasks which were "EXTREMELY High priority" and.. it got a little confusing.
But I was just waiting for an "MM" priority to show up. You know - "Very Medium." And perhaps "MMM" for "EXTREMELY Medium."
Makes about as much sense as "Very Null."
Good WTF.
Admin
The TRUE wtf is that they didn't define the method isUberNull!
Admin
Followed, of course, by isExcruciatinglyNull, damnThatsTheNullestThingEVER, politicianIQNull, and finally isNullAndNotNull.
Dave
Admin
What about kindaNull or sortaNull?
Admin
I wonder how people map those values to the database... do they put in a null into the field and have another bit column called veryFlag
Admin
Only since 2.0, though.
This is a fine WTF. I hereby decree this to be the new "FileNotFound." I can make decrees, right?
Admin
I think that this is quite funny, the function named isVeryNull made me laugh. However, I can also see the point to this, due to the nature of floating point numbers.
When comparing two floating point numbers, you'd normally have to do something like
if( abs(a - b) < cuttoff_value) { ...
this function makes that much simpler
if( isNull( a - b)) { ...
Funny names, still. :)
Admin
Admin
Knowing that Alex routinely obscures a submission by changing the language of the code, I wonder if it was Java or C# originally. If it was, then this is a hell of a WTF, but not an altogether shocking one. I've seen many well-meaning newbies decide that, say, a java.lang.Integer is far too heavyweight, and such people go to ridiculous lengths to avoid using wrapper classes.
If only universities would start teaching that premature optimization is the root of all evil.
Admin
So what's wrong with plain old 0?
Admin
Come on, isVeryNull() was written later by a developer making fun of it.
Admin
And the ever popular isNotOnlyVeryNullButFileNotFoundToo
Admin
So.. anyone care to guess what kind of system considers 0.0 to be null, but at the same time can't define isNull as "return _value == 0.0;"?
If they have a tolerance around 0, then one would presume they were doing math on the number. But why would you want a statement like isNull(a + b)? I mean, what would that even mean? If they aren't doing math to get the value, then they could always set the value equal to 0 (I mean, there's no chance that one compiler is going to convert 0 to a double differently from another compiler), so why bother with a tolerance?
Admin
How is zero represented in this brilliant scheme?
final public static double zero = 0.0002; // notQuiteNull
??
Admin
Nullable types are based on generics and as such did not exist until .NET 2. Prior to that, you had to wrap it or box it.
Admin
It's too bad there's no way to distinguish between zero and "very null". Zero is a pretty useful and meaningful value.
And when they set something to "null" or "very null", I wonder what value(s) they use...
Admin
Erhm. With doubles, everything is wrong.
Admin
What, no "fist!", "First!" or "frist!" post? I'm losing my faith in the trolls. Or they're starting to get that the joke isn't funny anymore.
Null is a value between 0.0001 and 0.0000000001, dumb@$$es!
Admin
"Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".
Admin
I would like to propose a system for a continuum of NULL values.
double nullDegree(double _value)
{
return Math.abs(_value);
}
double isAntiNull(double _value)
{
if (_value > 0)
{
return 1;
}
else
{
return 0;
}
}
This way we can determine how null something is as well as if it's anti-NULL. Meaning if two NULLs are of equal degree then summing them would annihilate the values if one is NULL and the other is anti-NULL.
Admin
I would imagine it goes to follow that:
All work and no play makes Jack a Very Null boy.
Admin
Admin
Or between -0.0000000001 and -0.0001
Admin
What about "I can't believe it's not null"?
Admin
I wonder if they have a IsPartiallyNull() method?
Admin
public static System.Boolean HabenSieEineNull(System.Double derValue)
Admin
Fist!
Admin
Doesn't schools teach the concept of NaN (Not A Number). I mean, even C and C++ support these!
This code is definitely not NaN-friendly.
Admin
public class VeryPaulaBean extends PaulaBean
{
public String getVeryBrillant()
{
return "Very brillant";
}
}
Admin
what about "isMotherOfAllNulls" ?
Admin
HL7, the messaging standard for Healthcare, defines seven different "Flavors of Null". There. Not a lot of people know that.
Admin
Could I have a dish of raspberry null, please?
CAPTCHA: picture
Admin
Do they have a "cookies and cream" flavor?
Admin
Well, quite a bit actually. This obnoxious code not withstanding, there is quite a bit of difference between "There is no value" and "There is a value, and it's 0." Non-existance of data is a very important distinction; and I could even see a need for explanitory metadata explaining WHY a field is blank -- for example, there might be a field that's blank since creation and another that's been purposely MADE blank. You could do worse than calling the first case "very null." Of course, you'd still be wise to make sure the discrete value "0" failed both tests.
Interestingly enough, what's far worse than non-nullable integers in .NET is the fact that Date is also a value type. No null dates, but every .NET date time picker handles nullable values and every customer wants them. We wound up using midnight on January 1st, 1900 (the default from one or another of our legacy systems, probably Access), and it kind of came back to haunt us. Bug reports with "Date Time Field XxX displays January 1st" were very, very common.
Admin
Actually, when I go to the Elegant Steak House (tm) (patent pending), I always make a point mention that I'd like the steak prepared "extra medium."
Admin
This space intentionally left blank? :)
I agree, sometimes it would be nice to have some kind of distinction between not initialised and deliberately nulled out states. (And NaN, as a third special value.) But this is useful for debugging only, in production code you do not use uninitialised variables, do you? :)
Admin
Ah, yes, the inevitable stream of "0 is a value, where NULL is the absence of any value" philosophical discussions...and I cannot help myself from jumping into the fray:
In my humble, not entirely versed in the algebra of databases, opinion the necessity for a NULL is basically a limitation of our understanding of how to store, manage, and present data. It is also probably carried over from some historical application somewhere due to limited storage in early computers - there was not enough space to include 'valid / not valid / Brillant! / veryNULL' flags for data. So part of it is due to the physical nature of data storage (I'm sure that in most modern databases and strictly typed languages, NULLs are implemented internally with some sort of magic number or wrapped with a flag somewhere that is transparent to the programmer), and part due to presentation - especially in databases where information is transmitted in sequential, delineated form where there must be a fixed number of spaces; if things could be transmitted instead as entities with characteristics, the concept of NULL would probably not be required.
And now that I've said things which may or may not make any coherent sense, I think I'll depart.
Admin
<FONT color=#006400>Actually, when I go to the Elegant Steak House (tm) (patent pending), I always make a point TO mention that I'd like the steak prepared "extra medium."</FONT>
I hate, I Hate, I HATE--forum software!
(And you thought I was going to say "Peter Pan." But I ask you--what would be the point in hating peanut butter?)
Admin
It could be that it's written by some German coder who's supposed to be writing the code in English but hasn't got the hang of certain bits of the language yet. isZero and isVeryZero are actually reasonably accurate names/descriptions for the functions...
Admin
This is my favourite WTF since I started reading the daily WTF.
So simple, so elegant, so WTF.
Admin
Yeah, and using ints, longs and doubles and other silly things are also useless, as internally they are all zeros and ones. (As far as I know, most java implementations do use a pointer to a dummy singleton "null" object but causality is the other way around. They use this technique because there's no other sensible way to represent null, which is needed in a sensible language.)
Admin
So if you multiply 2 nulls together you may get verynull... nice.
Admin
After reading through all the comments, i'm still laughing. Good one. No eye-burning involved.
CATTCHA==ENTERPRISE
:)
Admin
Fools. Lisp already solved this over 40 years ago (tm) with Is-Null, Is-Pretty-Null, and The-Nullest. And you other guys are just NOW inventing these functions?
Admin
Then the real WTF is German being a very dull null language.
Admin
And in all that, he never noticed that using those values, you can't sort on priority? (Highs would be first, followed by Lows, and then Mediums)
Admin
Huh. Are we sure that by "Null" they don't mean "insignificantly small", for doing comparisons, for example?
double f1, f2;
...
if( isNull(f1 - f2) )
{
// f1 - f2 is almost 0
}
...
if( isVeryNull(f1 - f2) )
{
// f1 - f2 is very almost 0
}
In this case, it's a very poor name for a legitimately useful function. Though I prefer to make it explicit, and just #define an "epsilon" or "threshold" value somewhere to compare against...
#define EPSILON 0.00000001 // really small
...
if( fabs(f1 - f2) <= EPSILON )
{
// close enough
}
Then there's no confusion about what's actually going on.
Admin
A professor put it like this:
Lets say you are walking around downtown with 6 cents in your pocket. A beggar walks up and asks if you have a penny or nickel? Do you tell him "no"? If you're a bastard you do.