<div dir="ltr">On 3 June 2013 18:11, deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On Monday, 3 June 2013 at 07:30:56 UTC, Kapps wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Monday, 3 June 2013 at 07:06:05 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
There are functions that<br>
the author intended to be overridden, and functions that have no business<br>
being overridden, that the author probably never imagined anyone would<br>
override.<br>
What if someone does come along and override one of these, and it was never<br>
designed to work under that circumstance in the first place?<br>
At very least, it will have never been tested. That's not a very robust API<br>
offering if you ask me.<br>
</blockquote>
<br>
This is something just as important as the performance issues. Most of the time people will leave functions to simply use whatever the default is for virtual/final. If it's final, this works fairly well. The author hasn't put in the effort to decide how to handle people overriding their function. But with virtual by default, you don't know if the author actually considered that people will be overriding the function or if it's simply that they didn't bother specifying. I know the vast majority of my code is virtual, simply because I didn't specify the 'final' keyword 500 times, and didn't think about that I'd need to do it. The resulting code is unsafe because I didn't consider those functions actually being overridden.<br>
<br>
</blockquote>
<br></div>
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.<br>
</blockquote><div><br></div><div style>Then OOP is fundamentally unsafe, because the author will never consider all the possibilities!</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
If you want to create a class with customizable parts, pass parameters to the constructor. This isn't OOP what OOP is about.<br></blockquote><div><br></div><div style>Eh?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
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.</blockquote>
<div><br></div><div><div class="gmail_extra">Java is not compiled. If you compile Java code, all functions are virtual always.</div><div class="gmail_extra">It's impossible in D with separate compilation, and dynamic libraries seal the deal.</div>
</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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.<br>
</blockquote></div></div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>I'm not taking away your ability to make everything virtual, you can type 'virtual:' as much as you like.</div>
</div>