[Gambas-devel] "Overriding" virtual classes

Tobias Boege tobias at ...692...
Mon Jun 23 19:46:01 CEST 2014


On Mon, 23 Jun 2014, Tobias Boege wrote:
> Hi Benoit,
> 
> for the Graph class in gb.data, I thought of having a non-creatable Graph
> class (we had that topic already in the past) which is the interface
> necessary for all concrete graph implementations. This class exposes a
> Graph.Edges property to a virtual .Graph.Edges class whose interface and
> default implementation are also specified.
> 
> [...]
>
> If I now create a GraphMatrix class basing on adjacency matrices which
> Inherits Graph, I also need to point the Graph.Edges property to some
> concrete .GraphMatrix.Edges class which operates on the adjacency matrix.

Oh, wait. I think this problem just solved itself.

The above is actually a bad example. .Graph.Edges is certainly nothing worth
enough to have a distinct virtual class for (I'm thinking about the trouble
a user will have implementing their own Graph descendant).

"But things are different for enumerations", I thought, such as

  For Each myEdge In myGraph[myNode].InEdges
    ' ...
  Next

But to use this feature, we definitely *need* a non-virtual Edge class. An
analogous thought shows that it's necessary to have a non-virtual Vertex
class and quite frankly, it's a good feeling to be able to create arrays of
vertices and edges in Gambas so that I don't have to write dozens of _next()
methods.

So, I will provide Graph, Edge and Vertex and the users will need to
Inherit these classes in their descendants. This way, the implementation is
variable and the interface is stable. Problem solved.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk





More information about the Devel mailing list