<div dir="ltr">On 10 April 2013 17:01, Paulo Pinto <span dir="ltr"><<a href="mailto:pjmlp@progtools.org" target="_blank">pjmlp@progtools.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wednesday, 10 April 2013 at 06:03:08 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[...]<div class="im"><br>
<br>
I do use virtual functions, that's the point of classes. But most functions<br>
are not virtual. More-so, most functions are trivial accessors, which<br>
really shouldn't be virtual.<br>
OOP by design recommends liberal use of accessors, ie, properties, that<br>
usually just set or return a variable. Wen would you ever want @property<br>
size_t size() { return size; } to be a virtual call?<br>
</div></blockquote>
<br>
Yes, if you want to change its behavior in a derived class.<br></blockquote><div><br></div><div style>That really shouldn't be encouraged. Give me an example?</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

One nice feature of properties is that you can trigger actions when assigning/reading from properties.<br></blockquote><div><br></div><div style>That doesn't make the property virtual, that makes the virtual that the property calls virtual. You can't have a derived class redefining the function of a trivial accessor. If it has a side effect that is context specific, then it would call through to a separate virtual. And this would be a controlled and deliberate case, ie, 1 in 100, not the norm.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is very used in OO GUI and DB code in other languages.</blockquote><div><br></div><div style>I know, it's an abomination, and the main reason OOP is going out of fashion.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Can you demonstrate a high level class, ie, not a primitive tool, but the<br>
sort of thing a programmer would write in their daily work where all/most<br>
functions would be virtual?<br>
</blockquote>
<br></div>
I have lots of code from JVM and .NET languages with such examples.<br>
<br>
OO code in the enterprise world is a beauty in itself, regardless of the language.<br></blockquote><div><br></div><div style>That's not an exampe. I want to see a class where every function SHOULD be overloaded... That sounds like a nightmare, how can anyone other than the author ever expect to understand it? The fewer and more deliberately controlled the virtuals, the better, by almost every measure I can imagine.</div>
</div></div></div>