How null breaks polymorphism: or the problem with null

http://eureka3d.com/blog/?p=21

Do you find yourself constantly checking for null

Does your clever little method now look like a small mess after you’ve incorporated your null checks? Do you find yourself asking, ‘how is anyone else going to ever follow that now’?

If so, then how is this for a neat idea? Write a language with a keyword that tells the compiler that a parameter you are passing or expecting to receive from a method cannot be null, and as a result of this checking, know that you can code the method with a lot more clarity and an immunity to null pointer exceptions.

Steve Riley’s 2 part blog on this subject poses the above scenario and some solutions even for those of us stuck in a language we cannot neuter the nulls. It’s a very enjoyable read.

Leave a Reply