On Monday, 6 February 2023 at 12:22:19 UTC, Matt wrote:
I am (still) writing a 3D graphics engine, and was considering
my choices for a scene graph.
Originally, I was going to use classes derived from my base
SceneNode class for the nodes of the graph, but would this
instead be a better situation to use template mixins instead of
potentially having to include a lot of information in the base
class? Or should I go with the traditional "everything is
derived from the base class"?
I understand if this is light on details, I'll try and provide
more if necessary, but I'm really not far into the design
beyond this, and was wondering which would make for an easier
path in the future
Use classes. Mixin template are only relevant to types which
understands the mixin template or when you want to create a
similar object with similar behavior, but they mustn't be the
same thing. That means, you need to ducktype everything in order
to work which could bring a template hell in your code. Unless
you try to do generics in your code or make it componetized
rather than inherited, but that could affect your coding style by
manually passing the node that your object has, this can be quite
the manual work though.