[webkit-dev] Should overridden methods use 'virtual' keyword in addition to 'override'?
darin at apple.com
Fri Mar 4 14:02:44 PST 2016
> On Mar 4, 2016, at 10:51 AM, Michael Catanzaro <mcatanzaro at igalia.com> wrote:
>> - Style guide should encourage programmers to use final instead of override whenever possible. I suspect many of the functions that currently are tagged override should be final instead. Agreed?
> What's your reasoning for this suggestion?
These are internal interfaces within the project. If we later find out we need to override in a derived class, at that time we can change final to override.
As long as we don’t need to override in a derived class, having something marked final instead of override lets the compiler do more optimization. And it tells someone reading the code that there is no further overriding in derived classes. Also, the word final is shorter.
It’s similar to why we want people to make things as private as possible, preferring private to protected and protected to public. We can always make them more private later.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev