Context:
This is for a library that reads some old games formats representing 3D models.
Let's call these low-level formats PRM1, PRM2, PRM3 and PRM4.
- each of these formats contains the
position,originandprimitivesof 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 implementsIModeldirectly, it would contain the whole mesh generation process since it's unique, effectively removing duplicate code PRM1,PRM2,PRM3andPRM4would then derive fromModeland they would only contain the reading from the binary file itself through theModel(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.
Question:
Is this a perfectly valid approach/pattern or is there something I am missing ?