Click here to Skip to main content
15,892,809 members

Survey Results

Do you use null values or magic numbers?   [Edit]

Survey period: 11 Dec 2006 to 17 Dec 2006

Many languages allow you to store null values in place of actual data. If you have no data for a value do you null it or store, say, -1?

OptionVotes% 
I always use null values in code49937.18
It depends on the situation74255.29
I never use null values in code1017.53



 
QuestionStoring null Pin
SDF_of_BC17-Dec-06 1:13
SDF_of_BC17-Dec-06 1:13 
AnswerRe: how to hide weeks of other months in asp.net? Pin
MatrixCoder15-Dec-06 18:24
MatrixCoder15-Dec-06 18:24 
QuestionWhat you mean by a 'null' value? Pin
Nisamudheen15-Dec-06 1:39
Nisamudheen15-Dec-06 1:39 
AnswerRe: What you mean by a 'null' value? Pin
MatrixCoder15-Dec-06 18:22
MatrixCoder15-Dec-06 18:22 
QuestionRe: What you mean by a 'null' value? Pin
Nisamudheen16-Dec-06 0:20
Nisamudheen16-Dec-06 0:20 
AnswerRe: What you mean by a 'null' value? Pin
Signal-917-Dec-06 17:01
Signal-917-Dec-06 17:01 
QuestionRe: What you mean by a 'null' value? Pin
Nisamudheen17-Dec-06 20:34
Nisamudheen17-Dec-06 20:34 
GeneralOften, it's language driven Pin
W Balboos, GHB14-Dec-06 9:41
W Balboos, GHB14-Dec-06 9:41 
Sometimes null's are convenient and comprable (a useful feature), such as in C/C++, with a fine value which can be evaluated (such as for pointers). null == null (== 0)

In this case, it depends upon the context, but it is usually used. There is an assumption that the compiler initializes non-pointer types (such as int) to 0, or its equivalents.



On the other hand, SQL nulls are undefined. They can be used, but the only real operation is to test for them. In SQL, null != null.

In this case, I may allow nulls to make data entry simpler, but just as often, I'll create a default value for a field so I can test for it mixed with non-null'd data. There was an application I created that used zero as a possible true value, and my 'null' was -99.99 .


So, upon general consideration, I tend to use evaluatable null's when available. Often, such as pointer values, this is the only sensible way to go if you wish to compare those assigned data space with those that have none.


Definitely a lot of personal taste involved in this.




"The difference between genius and stupidity is that genius has its limits." - Albert Einstein

GeneralNot sure what the question is... Pin
Fedor Hajdu14-Dec-06 2:43
professionalFedor Hajdu14-Dec-06 2:43 
GeneralRe: Not sure what the question is... Pin
Steve Hansen14-Dec-06 4:22
Steve Hansen14-Dec-06 4:22 
GeneralRe: Not sure what the question is... Pin
Fedor Hajdu14-Dec-06 4:35
professionalFedor Hajdu14-Dec-06 4:35 
GeneralRe: Not sure what the question is... Pin
Jon Rista14-Dec-06 16:09
Jon Rista14-Dec-06 16:09 
GeneralRe: Not sure what the question is... Pin
Fedor Hajdu14-Dec-06 5:00
professionalFedor Hajdu14-Dec-06 5:00 
GeneralWhat? Pin
ed welch13-Dec-06 10:26
ed welch13-Dec-06 10:26 
GeneralRe: What? Pin
Bradml14-Dec-06 0:45
Bradml14-Dec-06 0:45 
GeneralMagic numbers are a special case = bad Pin
Shawn Poulson13-Dec-06 5:18
Shawn Poulson13-Dec-06 5:18 
GeneralRe: Magic numbers are a special case = bad Pin
Corporal Agarn14-Dec-06 8:44
professionalCorporal Agarn14-Dec-06 8:44 
GeneralRe: Magic numbers are a special case = bad Pin
codemunkeh14-Dec-06 15:02
codemunkeh14-Dec-06 15:02 
General.In C#, please use MinValue or MaxValue Pin
Dale Thompson12-Dec-06 7:25
Dale Thompson12-Dec-06 7:25 
GeneralIn C#, please use MinValue or MaxValue. Pin
Dale Thompson12-Dec-06 7:23
Dale Thompson12-Dec-06 7:23 
GeneralRe: In C#, please use MinValue or MaxValue. Pin
Ri Qen-Sin12-Dec-06 13:37
Ri Qen-Sin12-Dec-06 13:37 
GeneralRe: In C#, please use MinValue or MaxValue. Pin
Kamarey16-Dec-06 22:42
Kamarey16-Dec-06 22:42 
GeneralRe: In C#, please use MinValue or MaxValue. Pin
jhwurmbach18-Dec-06 2:38
jhwurmbach18-Dec-06 2:38 
GeneralRe: In C#, please use MinValue or MaxValue. Pin
Ri Qen-Sin22-Dec-06 14:09
Ri Qen-Sin22-Dec-06 14:09 
GeneralThe default keyword Pin
WillemM11-Dec-06 5:40
WillemM11-Dec-06 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.