Daniel Pitts wrote:
There is no clean way to extend at runtime. While a Vertex may seem
like a Point to you, its really not a Point. A Vertex has a location,
and has related Edges, where a Point simply has a Location. Perhaps
you really want a Location2d and Location3d, and then a class Point<L
extends Location>, and class Vertex<L extends Location>
If you think about abstracting the concept of a location from the
concept of a point/vertex, you simply this model a bit.
I was sort of thinking the same. A point is a fairly lightweight
concept and trying to extend it to a class that add so little to the
point might be a misfeature.
I think the OP should consider skipping a Vertex class and going
straight for Strips, Meshes, Fans and Polygons. These would naturally
have lists of Points (has-a) and should probably implement their own
methods for finding edges and adjacent points, because they'll each need
slightly different algorithms for best efficiency.
Points might even be implemented internally just by 2d arrays.
Operations on points could just be static methods. Don't forget that
while fairly small, there is overhead associated with method calls when
inheritance might be involved.
Now you've gone a little to far in the opposite direction. It is
important to avoid primitive obsession in program design. I think a
connect via itself. Unless you need a specialized algorithm for some
reason, use the cleanest abstract approach.