3 ms·
Yes, NULL means the lack of something. Very simple. But not having something when you think you do is by far the most common class of errors. So if you are alwa
by hawkice 11y ago
Yes, NULL means the lack of something. Very simple. But not having something when you think you do is by far the most common class of errors. So if you are always clear about the fact you either WILL have something or MAY have something (instead of it being hidden), you can write software that you are more confident in, and (hopefully) crashes with completely opaque errors less frequently. [This is why I happen to completely agree w.r.t. Null objects -- I don't see a point unless it means something extremely specific. Like, File openFile() could return a UnreadableFile null-ish object as an error code, but that seems worse than just having checked exceptions.]
- userbinator 11y agoBut not having something when you think you do is by far the most common class of errors. In all the things I've debugged that's almost never been the actual error, but rather a symptom of something else (running out of memory, failed file opening, etc.) that needs further investigation. In my experience the "check for null, skip processing and continue if a value is null" way is a far worse option since it causes errors to propagate further, whereas a crash is an unmistakable call to action.
- hawkice 11y agoDepends a lot on programming language. Stuff like that tends to end up in Exceptions, if you have decently useful exceptions available.