4 ms·
This obfuscates code, and I remove it wherever I see it. Sometimes people are too clever for their own good. Use an object. Override a method, FFS.
by datashaman 15y ago
This obfuscates code, and I remove it wherever I see it.
Sometimes people are too clever for their own good.
Use an object. Override a method, FFS.
- barrkel 15y agoAny trivial example demonstrating how something like this works will seem obfuscatory, because examples are usually trivially solved with other approaches. But see the Expression Problem[1] for the deep problem. Whether it's an appropriate solution depends on whether introducing new operations or new data types is more common; and where the modularity boundaries are. For example, what if the base class in the hierarchy doesn't have a method for the task you want to perform, and you can't add one because it belongs to third party code, and nor can you implement it appropriately for every descendant? [1] http://en.wikipedia.org/wiki/Expression_problem http://en.wikipedia.org/wiki/Expression_problem