This is for a library that reads some old games formats representing 3D models.
Let's call these low-level formats
- each of these formats contains the
primitivesof a 3D model
- they have minor implementation differences but in the end produce the same type of content
- currently they all implement an
IModelinterface from which data is read to produce graphics
Now, I end up with duplicate methods in each of these types, they all do the same thing:
private GetMesh(IPolygon, ...)
public GetMesh(...)calls above method to produce a 3D model
So I thought, why not ... ?
- making a
Modelclass that implements
IModeldirectly, it would contain the whole mesh generation process since it's unique, effectively removing duplicate code
PRM4would then derive from
Modeland they would only contain the reading from the binary file itself through the
Model(Stream stream)constructor entry point
While this sounds the way to go, it feels weird as now low-level types depend on a high-level type.
Is this a perfectly valid approach/pattern or is there something I am missing ?