C#C
C#3y ago
3 replies
hugeman

❔ Inheritance or composition?

For example, blender, C4D or any 3D modelling program would have a scene with a hierarchy of objects (e.g. cube, mesh, etc). These would obviously need a position associated with them... but would it be a better idea to use composition such that you have a
TransformationInfo
object stored as a field (or in a dictionary maybe, similar to what unity does with components), which stores the position, scale and rotation data?

Another example that really made me think of this question is premiere pro, specifically video clips. Video clips are obviously going to have some sort of manually controllable position, and also a scale value (and an origin point to assist the scale). But the way premiere pro presents that data is in the effects panel as the "Motion" effect, making me think that internally premiere pro stores all that data in an effect instead of in the clip class or struct or however they do it. If they wrote it using C structs I could understand because audio clips don't really need a position. However if it were C++, would it not be a better idea to have
VideoClipObject
which stores that size and scale data, and also extends
ClipObject
which is the base for every clip? Or does their way of having (I imagine) a single clip class/struct, and just tieing all the video/audio/effect data in effects, make it a better design?
Was this page helpful?