Programmers use Null as different flags. It can hint an absence, an undefined value, en error etc. Multiple semantics lead to coupling and errors.
- Coupling among the callers and the senders.
- Mismatch among the callers and the senders.
- If/Switch/Case Polluting.
- Null is not polymorphic with real objects. Hence Null Pointer Exception
- Null does not exist on real world. Thus it violates Bijection Principle
Null: The Billion Dollar Mistake
He is not our friend. It does no simplify life or make us more efficient. Just more lazybones. It is time to stop…
- APIs, Databases and external systems where NULL does exist.
Most linters can show null usages and warn us.
- Null is the billion dollar mistake. Yet, most program languages support them and libraries suggest its usage.
I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.
This article is part of the CodeSmell Series.