So, I'm in the process of designing a small system for which I'm starting out with making a class diagram. (Before however I proceed, I guess it is fair to say, that the properties visualized here have different naming in the real system)
The small snippet displays the following:
- Engine can generate either a
DefaultAlgorithmor aDecoratedAlgorithm Engine,DecoratedAlgorithmandDefaultAlgorithmhaveAlgorithmas an associated propertyEngineneeds the properties fromAlgorithmin order to generate eitherDefaultAlgorithmorDecoratedAlgorithmDefaultAlgorithmandDecoratedAlgorithmboth need the properties fromAlgorithmbecause those properties are metadata that tells how the algorithms were generated.DefaultAlgorithmandDecoratedAlgorithmwill besides being consumed by other classes (that readsalgoand corresponding properties) also be persisted in a database where nested properties might not be desirable.
When I look at above diagram, I dont feel that things look quite right, for example will the properties of Algorithm be deeply nested, making me have to write awkward code to access the properties.
To me, possible alternative options could be:
- Extend
DefaultAlgorithm,EngineandDecoratedAlgorithmwithAlgorithm, not caring about "Composition over inheritance" - Carelessly repeat myself and add the properties to respectively
DefaultAlgorithm,EngineandDecoratedAlgorithm
I know this might be a broad question, but what I hope with this question is to get some feedback on my thought process (Since I fear that I might be overthinking this)
