2 ms·
In OO, isn't this territory covered by the "Missing Object" pattern? Also, aren't there new statically typed languages that define the missing object class for
by stcredzero 18y ago
In OO, isn't this territory covered by the "Missing Object" pattern? Also, aren't there new statically typed languages that define the missing object class for you?
A pernicious thing you find in Smalltalk at certain shops is finding lots of methods defined on UndefinedObject (nil) so that it can act as a Missing Object. (Like comparison operations.) The problem, is that this often results in not knowing what the heck to expect in a variable.
This is very bad. You can't change your mind about this! It can also break the system in insidiously subtle ways. (Sometimes things work because an exception is thrown!)
- raganwald 18y agoI'm not a huge fan of trying to make One UndefinedObject To Rule Them All: http://github.com/raganwald/homoiconic/blob/master/2009-02-02/hopeless_egocentricity.md#readme http://github.com/raganwald/homoiconic/blob/master/2009-02-0...
- stcredzero 18y agoYes. If possible, if a variable is for a Floogle, then make it always have a Floogle in it. If the thing is not there, represent it with a MissingFloogle. I think dynamic languages would be wise to support this explicitly. (There's always a Missing subclass of every type.)