3 ms·
Traits and contracts or interfaces, but even still inheritance has it's merits. Being fast and easy is a benefit, and I find defensive programming in extensible
by ehnto 3y ago
Traits and contracts or interfaces, but even still inheritance has it's merits. Being fast and easy is a benefit, and I find defensive programming in extensible systems can benefit from a foundation of expecting inheritance.
- josephg 3y agoWhat do you mean by this sort of defensiveness? Can you give an example?
- ehnto 3y agoFor example in a plugin system, I can say you must inherit from BasePlugin and in code I can enforce that, BasePlugin can then have some protected functions that I can disallow from being overridden. It's good for frameworks and extensible systems where your code needs to guarantee certain things will happen when running third party code.