6 ms·
It's a trap! You think it's safer to return null than raise an exception. After all, the caller just needs to check. Of course, sometimes they don't. So if y
by ben509 7y ago
It's a trap!
You think it's safer to return null than raise an exception.
After all, the caller just needs to check. Of course, sometimes they don't.
So if you're lucky it blows up in some completely unrelated part of your application. Being null, it carries no information as to where or what the error was.
If you're not lucky, it's saved to disk. Now you have a silent null somewhere in your data that blows up potentially months after the actual error.
- heavenlyblue 7y agoWell... No null check is essentially a tech debt that you are going to pay. The beauty of tech debt is that most of the time the universe is responsible for making you pay up for not making the right decisions in the first place. Sometimes you get lucky (we find other ways of dealing with the issue)... Sometimes you don’t.