News for hackers. Stuff that matters.

anonnona

Re:Why we've banned null in our codebase on Friday January 04, 2013 @12:59PM (#5008802)
I don't think you understand. If you don't allow null by default in your type system then you don't have to check for it when you don't need it.

Dealing with user input is a separate issue, yes you need to validate it. The problem with every type allowing null is that it infects EVERY object for a situation that isn't always needed or wanted.

Re:Why we've banned null in our codebase on Friday January 04, 2013 @12:41PM (#5008708)
In that world you have bugs lying in wait inside the code ready to rear their head at inopportune times, better to not allow their existence at all. Also in terms of difficulty of fixing bugs its a lot easier to fix bugs at compile time on your machine then it is later on in the release cycle. I think this kind of attitude is the reason why maintenance is the most expensive part of software development. It's also the work involving the most drudgery.
Re:Why we've banned null in our codebase on Friday January 04, 2013 @12:02PM (#5008500)
I think you are missing the point.

The problem is that for the most part needing to check whether an object is null/"valid" should be an exceptional case, not a common one. Most object variables do not need to have the optional/null state. For languages that allow every object to be null you create a situation where you need to have null checks for every object you encounter unless you come up with some error prone convention outside the language itself. Every method/function has to handle the nulls, it's not clear whether an object will be null when passed into a method or not, and if you are writing APIs for people to use, you must check for nulls because you cannot expect much from the user of the apis.

TLDR; Having non null objects by default reduces the amount of code, which in turn increases the correctness of the code.