Hacker News new | ask | show | jobs
by thwest 4451 days ago
Why though? I'm of the opinion that the error should be handled at the place that produces the first NULL/None. Objects should be valid.
1 comments

> Why though? I'm of the opinion that the error should be handled at the place that produces the first NULL/None.

Producing NULL (or whatever the languages equivalent is) isn't an error -- if there was an error, it would be throwing an exception, not returning NULL. The idea of "do this chain of operations propagating nulls encountered at any point" is reasonably useful.

I just hate NULL standing in for a boolean notion of existence, I'd rather see a separate boolean member indicating the validity of the other member (string middle_name; boolean has_middle_name;). Or in a strongly typed language an Option/Maybe type. Just assigning things NULL sometimes has the problem of people looking at the object and assuming everything will always be populated.