On 3 June 2013 18:20, Jacob Carlborg <[email protected]> wrote: > On 2013-06-03 10:11, deadalnix wrote: > > The whole concept of OOP revolve around the fact that a given class and >> users of the given class don't need to know about its subclasses >> (Liskov's substitution principle). It is subclass's responsibility to >> decide what it override or not, not the upper class to decide what is >> overriden by subclasses. >> >> If you want to create a class with customizable parts, pass parameters >> to the constructor. This isn't OOP what OOP is about. >> >> The performance concern is only here because things has been smashed >> together in a inconsequent way (as it is often done in D). In Java for >> instance, only overriden function are actually virtual. Everything else >> is finalized at link time. Which is great because you are able to >> override everything when testing to create mock for instance, while >> keeping good performance when actually running the application. >> > > I've read a book, Effective Java, where it says, something like: > > If you don't intend your class to be subclassed make it final, otherwise > document how to subclass and which methods to override.
Sounds like even they know the truth I speak, but they must enforce this by convention/documentation rather than offering strict guarantees ;) It's interesting (but not at all surprising) that C# which is much more modern decided to go the C++ way rather than the Java way.
