4 ms·
I find the Null Object Pattern and hiding nulls to be dangerous. Why pretend or give the illusion that something exists when it doesn't? I prefer explicit chec
by ahallock 8y ago
I find the Null Object Pattern and hiding nulls to be dangerous. Why pretend or give the illusion that something exists when it doesn't?
I prefer explicit checks. I don't mind `Maybe` because that's still explicit and enables you to chain operations, avoiding repetitive null checking; the consumer must still handle the null case.
- chooseaname 8y agoWith the null object pattern, your logic still has to determine if it needs to create a null object or not. The difference is that code is down where it needs to be not further up where it can be duplicated or have more abstraction built around it that just complicates what should be really simple code at that point.
- ahallock 8y agoInteresting. I'd have to see some concrete examples to understand better. Where I've seen it used caused issues because it was masking data integrity issues.