Im new to object design and Im trying to figure out which design is better.
I have a Material entity which can have multiple versions. I have two designs, one is with nested classes, and the other is flat, more like a database table.
Nested example (pseudo code):
class Material name path = "some/path/" + name List MaterialVersion class MaterialVersion versionNumber path = "some/path/materialName/" + versionNumber
MaterialVersion is nested inside Material and this way its easier for me to display it in the UI.
But I’ve tought of another design like this:
class Material name version path = "some/path/" + name + version class MaterialCollection List Material getUniqueMaterialsByName getMaterialVersions
I have lost the MaterialVersion class but I need some methods that I can query all of the materials so I can display them in a tree like this
-- Material 1 ---- V1 ---- V2 -- Material 2 ---- V1
I think the first one is better for my use but I would like to hear some opinions or even some other solution.