The tag has no wiki summary.

learn more… | top users | synonyms

59
votes
14answers
8k views

Should one check for null if he does not expect null?

Last week, we had a heated argument about handling nulls in our application's service layer. The question is in the .NET context, but it will be the same in Java and many other technologies. The ...
12
votes
5answers
3k views

null pointers vs. Null Object Pattern

Attribution: This grew out of a related P.SE question My background is in C / C++, but I have worked a fair amount in Java and am currently coding C#. Because of my C background, checking passed and ...
30
votes
10answers
7k views

If null is bad, why do modern languages implement it? [closed]

I'm sure designers of languages like Java or C# knew issues related to existence of null references (see Are null references really a bad thing?). Also implementing an option type isn't really much ...
54
votes
24answers
13k views

How can I explain the difference between NULL and zero?

Working on a problem that uses the percent change formula: percent change = 100 * [(new value - old value) / old value] How would I explain the difference if new value or old value = NULL, rather ...
7
votes
9answers
8k views

Best way to handle nulls in Java?

I have some code that is failing because of NullPointerException. A method is being called on the object where the object does not exist. However, this led me to think about the best way to fix ...
6
votes
6answers
7k views

What does it mean to do a “null check” in C or C++?

I have been learning C++ and I am having a hard time understanding null. In particular, the tutorials I have read mention doing a "null check", but I am not sure what that means or why it's necessary. ...
19
votes
13answers
3k views

Why are null references shunned while throwing exceptions is considered okay?

I don't quite understand the consistent bashing of null references by some programming language folks. What's so bad about them? If I request read access to a file that doesn't exist then I'm ...
2
votes
2answers
126 views

Handling “unspecified” values in software

So I'm working on a software product where we have a number of fields that the customer can leave blank, some of which are numeric. To persist these in the database we use nullable columns. Easy ...