

Why NULL is Bad? - yegor256a
http://www.yegor256.com/2014/05/13/why-null-is-bad.html

======
theforgottenone
Meh. Using a dummy object doesn't solve the problem of testing if you got the
dummy or not. And throwing a specific exception is still an exception, but now
more code to maintain, and only for exceptional circumstances (or is it really
exceptional?).

Yeah, Null Ref Exception isn't as pretty as a more domain specific one, but
the essential thing happens regardless: the program throws as soon as you try
to access a member. And if you just pass your results on to another function,
that function could be testing its inputs, and throwing your exception there
as an explicit ArgumentNull instead of Null Ref.

I prefer less to more code, especially for an error I wont even expect to ever
see. If it something I do expect, then sure, make a fancy exception and throw
that.

------
rectangletangle
I don't like using null generally, because it results in having to use a bunch
of unwieldy if statements. It's much nicer to have the notion of an "empty"
object, which supports the same interface as a normal object. Python's lists
are a good example of this, as opposed to passing around a bunch of lists or
nulls, pass around empty or occupied lists. Both of course support the same
interface. This negates the need for a bunch of if statements, which are
cumbersome and easy to forget.

