[Networkit] Declaration of Graph as final

Florian Weber uagws at student.kit.edu
Thu Jul 2 08:20:16 CEST 2015


> Now I wonder why. Is there a reason for this, maybe simply for better compiler 
> performance?

IIRC I made this change a relatively long time ago. I believe the reason
was something along the lines that Graph didn't have any virtual methods
besides an unused virtual destructor and was therefore really not
something that inheriting from was overly usefull. Basically I removed
that virtual-keyword and made the class final.

Aka: There was not some super-deep reason aside from “people might not
be aware of the restrictions and do it wrong”.

However: The reasoning that graph provides no virtual functionality (and
it should be noted, that it is an inherent limitation of C++'s design
that it is impossible for member-templates to be virtual!) still
applies, the same is true for the fact that Graph is already a quite
large class and that this won't go away for anything that inherits from
it, so the question would be what you hope to achieve that way:

* You cannot reasonably change the way the graph stores any of it's data
* You cannot reasonably change the way existing methods are implemented
* You cannot access anything in a deriving class that you couldn't
access from a free function as well

(These are inherent limitations of the current API that are basically
impossible to change, aside from it not being a good idea to change those.)

Basically: Even if Graph wouldn't be final, inheriting from it would
probably be a very bad idea. I am not the person to decide this, but if
I were, I'd demand at least a much more thorough reasoning of what you
are trying to accomplish here, before considering changes.


-------------- n�chster Teil --------------
Ein Dateianhang mit Bin�rdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigr��e  : 819 bytes
Beschreibung: OpenPGP digital signature
URL         : <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150702/67f520ae/attachment.sig>

More information about the NetworKit mailing list