3 ms·
>With such polymorphism all hope is lost to be able to know the things that can happen. Implementations of the virtual method are not closed - they could come f
by coldtea 8y ago
>With such polymorphism all hope is lost to be able to know the things that can happen. Implementations of the virtual method are not closed - they could come from anywhere in the codebase.
Anywhere in the codebase that satisfies the interface (or inherits from some base class) -- which is trivial to find, and what you want.
Who said they had to be closed?
And what if you need a plugin architecture for example?
- jstimpfle 8y agoIf the cases are fixed, that should be reflected in simpler code. The code can only be simpler if it takes advantage of the fact that the cases are fixed. Because of that it's kind of required to "close" them. A plugin architecture is an entirely different kind of beast, and rarely needed. It requires some sort of interface to achieve the decoupling. Inheritance is one option here, albeit an ugly one.