3 ms·
As he points out in the article, unlike .NET extension methods, this (clever) technique requires classes to inherit from a special superclass before you can add
by mattw 16y ago
As he points out in the article, unlike .NET extension methods, this (clever) technique requires classes to inherit from a special superclass before you can add extension methods to them. If you're able to change a class' inheritance that way, why not add the methods directly to it?
This falls squarely into my "neat idea, no practical use" category, unless someone can enlighten me with a use case...
- Myrth 16y agoOne practical use: you want the core files to be easily upgradable by overwriting over old files, without loosing the customizations. EDIT: Which means it's useful technique for app developers to allow easy customizations by others. EDIT2: By example: Magento's framework is able to add or CHANGE existing methods without updating core files, which was one of the strongest reasons for its great success despite various shortcomings.
- mattw 16y agoInteresting. Thanks!
- cdmckay 16y agoThe main application I can see is for API designers who want to give their users the ability to augment core classes without having to edit the source. That way when users upgrade their libraries, they can overwrite the old sources without having to re-add all their customizations.