3 ms·
It seems a little odd to write code intending for it to do nothing. If that isn't a recipe for obfuscation...
by Retra 11y ago
It seems a little odd to write code intending for it to do nothing. If that isn't a recipe for obfuscation...
- masklinn 11y agoIt fits the tenets of OOP though, you ask an object to perform an operation, the "null" object just ignores the request.
- Retra 11y agoI'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.