Comment On It's Pretty Null

Most strongly-typed languages (C++, Java, C#, etc.) do not support NULL values for their primitive types (integers, floats, etc). There's quite a few ways to get around this limitation, from using an additional null indicator variable to wrapping the primitive type in a class, but the most common is using a "magic value" to represent NULL. Generally, this "magic value" is the smallest value possible, such as -1.79769313486232e308. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: It's Pretty Null

2006-05-08 15:06 • by PrisonerOfPain
C# does support null for value types. It's called nullable types and you define 'm like bool? name = null, or something.

Re: It's Pretty Null

2006-05-08 15:07 • by Karl von L.
Clearly, the designer's brain is very null.

Re: It's Pretty Null

2006-05-08 15:07 • by IQpierce

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.

Re: It's Pretty Null

2006-05-08 15:09 • by GoatCheez
The TRUE wtf is that they didn't define the method isUberNull!

Re: It's Pretty Null

2006-05-08 15:09 • by Dave
Followed, of course, by isExcruciatinglyNull, damnThatsTheNullestThingEVER, politicianIQNull, and finally isNullAndNotNull.

Dave

Re: It's Pretty Null

2006-05-08 15:13 • by AJ
What about kindaNull  or sortaNull?

Re: It's Pretty Null

2006-05-08 15:13 • by OneFactor
71693 in reply to 71691
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

Re: It's Pretty Null

2006-05-08 15:13 • by John Bigboote
71694 in reply to 71687
PrisonerOfPain:
C# does support null for value types. It's
called nullable types and you define 'm like bool? name = null, or
something.


Only since 2.0, though.



This is a fine WTF. I hereby decree this to be the new "FileNotFound." I can make decrees, right?

Re: It's Pretty Null

2006-05-08 15:14 • by Nand
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. :)

Re: It's Pretty Null

2006-05-08 15:16 • by marvin_rabbit
> isNull(double _value)

That was just the start. I'm sure the rest of the library was:

isTruelyNull(double _value)
isReallyQuiteSpectacularlyNull(double _value)
isNullToEndAllNull(double _value)
isMoreNullThanTheOtherNull(double _value)
isSoNullThatWhenItSitsAroundTheNullItSitsAROUNDTheNull(double _valu

Re: It's Pretty Null

2006-05-08 15:17 • by VGR
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.

Re: It's Pretty Null

2006-05-08 15:17 • by RiX0R
71698 in reply to 71695

So what's wrong with plain old 0?


 

Re: It's Pretty Null

2006-05-08 15:18 • by Rob
71699 in reply to 71688
Come on, isVeryNull() was written later by a developer making fun of it.

Re: It's Pretty Null

2006-05-08 15:19 • by lizardfoot
71700 in reply to 71691
Anonymous:
Followed, of course, by isExcruciatinglyNull, damnThatsTheNullestThingEVER, politicianIQNull, and finally isNullAndNotNull.

Dave


And the ever popular isNotOnlyVeryNullButFileNotFoundToo


Re: It's Pretty Null

2006-05-08 15:20 • by kipthegreat
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?

Re: It's Pretty Null

2006-05-08 15:20 • by bw
How is zero represented in this brilliant scheme?


final public static double zero = 0.0002; // notQuiteNull


??

Re: It's Pretty Null

2006-05-08 15:20 • by Code Monkey
71704 in reply to 71687

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.

Re: It's Pretty Null

2006-05-08 15:23 • by kanet77
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...


Re: It's Pretty Null

2006-05-08 15:24 • by PrisonerOfPain
71707 in reply to 71698
RiX0R:

So what's wrong with plain old 0?


 


With doubles, everything is wrong with 0.

Erhm. With doubles, everything is wrong.

Re: It's Pretty Null

2006-05-08 15:24 • by mjonhanson
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!

Re: It's Pretty Null

2006-05-08 15:24 • by ammoQ
"Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".

Re: It's Pretty Null

2006-05-08 15:26 • by Colin
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.

Re: It's Pretty Null

2006-05-08 15:27 • by ParkinT

I would imagine it goes to follow that:


All work and no play makes Jack a Very Null boy.

Re: It's Pretty Null

2006-05-08 15:29 • by PrisonerOfPain
71713 in reply to 71709
ammoQ:
"Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".

Than again, what would value_ mean in German? Seems kinda like the confusion people have when the first encounter the OR operator and think it works like XOR because of how it's used in natural language.

Re: It's Pretty Null

2006-05-08 15:30 • by kanet77
71714 in reply to 71708
mjonhanson:
Null is a value between 0.0001 and 0.0000000001, dumb@$$es!


Or between -0.0000000001 and -0.0001

Re: It's Pretty Null

2006-05-08 15:30 • by AR
71715 in reply to 71691
What about "I can't believe it's not null"?

Re: It's Pretty Null

2006-05-08 15:30 • by lrb
I wonder if they have a IsPartiallyNull() method?

Re: It's Pretty Null

2006-05-08 15:31 • by John Bigboote
71717 in reply to 71709
ammoQ:
"Null" means "Zero" in German and other languages.
I think those methods are badly named, should rather be "isZero" resp.
"isVeryZero".




public static System.Boolean HabenSieEineNull(System.Double derValue)

Re: It's Pretty Null

2006-05-08 15:33 • by Anonymous
71718 in reply to 71708
Fist!

Re: It's Pretty Null

2006-05-08 15:34 • by WeatherGod
71719 in reply to 71717
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.



Re: It's Pretty Null

2006-05-08 15:35 • by enterprisey
public class VeryPaulaBean extends PaulaBean
{
  public String getVeryBrillant()
  {
    return "Very brillant";
  }
}

Re: It's Pretty Null

2006-05-08 15:36 • by Occasional Browser
what about "isMotherOfAllNulls" ?

Re: It's Pretty Null

2006-05-08 15:37 • by Pat
HL7, the messaging standard for Healthcare, defines seven different "Flavors of Null".  There.  Not a lot of people know that. 

Re: It's Pretty Null

2006-05-08 15:45 • by Matt
71723 in reply to 71722
Anonymous:
HL7, the messaging standard for Healthcare, defines seven different "Flavors of Null".  There.  Not a lot of people know that. 


Could I have a dish of raspberry null, please?

CAPTCHA: picture

Re: It's Pretty Null

2006-05-08 15:45 • by lrb
71724 in reply to 71722

Anonymous:
HL7, the messaging standard for Healthcare, defines seven different "Flavors of Null".  There.  Not a lot of people know that. 


Do they have a "cookies and cream" flavor?

Re: It's Pretty Null

2006-05-08 15:46 • by dasmb
71725 in reply to 71698
RiX0R:

So what's wrong with plain old 0?




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.

Re: It's Pretty Null

2006-05-08 15:56 • by mrprogguy
71728 in reply to 71689
IQpierce:

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.



 


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."

Re: It's Pretty Null

2006-05-08 15:57 • by enterprisey
71730 in reply to 71725
Anonymous:
RiX0R:

So what's wrong with plain old 0?




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.


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? :)

Re: It's Pretty Null

2006-05-08 15:57 • by too_many_usernames
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.

Re: It's Pretty Null

2006-05-08 15:58 • by mrprogguy
71732 in reply to 71728

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."


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?)

Re: It's Pretty Null

2006-05-08 16:00 • by makomk
71733 in reply to 71713
PrisonerOfPain:
ammoQ:
"Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".

Than again, what would value_ mean in German? Seems kinda like the confusion people have when the first encounter the OR operator and think it works like XOR because of how it's used in natural language.


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...

Re: It's Pretty Null

2006-05-08 16:03 • by Stu
This is my favourite WTF since I started reading the daily WTF.



So simple, so elegant, so WTF.

Re: It's Pretty Null

2006-05-08 16:08 • by enterprisey
71736 in reply to 71731
too_many_usernames:
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.


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.)

Re: It's Pretty Null

2006-05-08 16:12 • by miguel
So if you multiply 2 nulls together you may get verynull... nice.

Re: It's Pretty Null

2006-05-08 16:15 • by Matt
After reading through all the comments, i'm still laughing.  Good one.  No eye-burning involved.

CATTCHA==ENTERPRISE
:)

Re: It's Pretty Null

2006-05-08 16:16 • by Mr Beeper
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?

Re: It's Pretty Null

2006-05-08 16:17 • by Anonymous
71741 in reply to 71709
ammoQ:
"Null" means "Zero" in German and other languages. I think those methods are badly named, should rather be "isZero" resp. "isVeryZero".


Then the real WTF is German being a very dull null language.

Re: It's Pretty Null

2006-05-08 16:17 • by JamesCurran
71742 in reply to 71689

IQpierce:
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".


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)

Re: It's Pretty Null

2006-05-08 16:17 • by reed
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.

Re: It's Pretty Null

2006-05-08 16:18 • by Stine
71744 in reply to 71713
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.
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment