Null serves a very valid purpose of representing a lack of value.
I will say I'm the most vocal person I know about the abuses of null and all the headaches and suffering they can cause especially when used liberally.
My personal stance is people may use nulls only when they can justify it's necessary and appropriate.
Example justifying nulls:
Date of Death is typically a nullable field. There are three possible situations with date of death. Either the person has died and the date is known, the person has died and the date is unknown, or the person is not dead and therefore a date of death does not exist.
Date of Death is also a DateTime field and doesn't have an "unknown" or "empty" value. It does have the default date that comes up when you make a new datetime which varies based on language utilized, but there is technically a chance that person did in fact die at that time and would flag as your "empty value" if you were to use the default date.
The data would need to represent the situation properly.
Person is dead date of death is known (3/9/1984)
Simple, '3/9/1984'
Person is dead date of death is unknown
So what's best? Null, '0/0/0000', or '01/01/1869' (or whatever your default value is?)
Person is not dead date of death is not applicable
So what's best? Null, '0/0/0000', or '01/01/1869' (or whatever your default value is?)
So lets think each value over...
- Null, it has implications and concerns you need to be wary of, accidently trying to manipulate it without confirming it's not null first for example would throw an exception, but it also best represents the actual situation... If the person isn't dead the date of death doesn't exist... it's nothing... it's null...
- 0/0/0000, This could be okay in some languages, and could even be an appropriate representation of no date. Unfortunately some languages and validation will reject this as an invalid datetime which makes it a no go in many cases.
- 1/1/1869 (or whatever your default datetime value is), the problem here is it gets tricky to handle. You could use that as your lack of value value, except what happens if I want to filter out all my records I don't have a date of death for? I could easily filter out people who actually died on that date which could cause data integrity issues.
The fact is sometimes you Do need to represent nothing and sure sometimes a variable type works well for that, but often variable types need to be able to represent nothing.
If I have no apples I have 0 apples, but what if I don't know how many apples I have?
By all means null is abused and potentially dangerous, but it's necessary at times. It's only the default in many cases because until I provide a value the lack of a value and something needs to represent it. (Null)