2 ms·
I'm probably full of crap about this. If you wrote "a = b/c" it would be silly to complain that this operation 'does nothing' whenever b == c happens to be tru
by Retra 11y ago
I'm probably full of crap about this.
If you wrote "a = b/c" it would be silly to complain that this operation 'does nothing' whenever b == c happens to be true, so by analogy, it's not too farfetched to think it's useless to write code that does nothing when given a null object.
On the other hand, multiplication and division are standardized and familiar operations. Object semantics differ for each kind of object, and it may not make sense to allow null objects for everything, and if you need one, you can always implement it later.
So it really depends on what you think the tenets of OOP are, and that's not a cut-and-dry question.