title: Extending object with properties in class diagram (Composition or inheritance)
body: <p><a href="https://i.stack.imgur.com/2WGB5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2WGB5.png" alt="enter image description here" /></a></p>
  <p>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)</p>
  <p>The small snippet displays the following:</p>
  <ul>
  <li>Engine can generate either a <code>DefaultAlgorithm</code> or a <code>DecoratedAlgorithm</code></li>
  <li><code>Engine</code>, <code>DecoratedAlgorithm</code> and <code>DefaultAlgorithm</code> have <code>Algorithm</code> as an associated property</li>
  <li><code>Engine</code> needs the properties from <code>Algorithm</code> in order to generate either <code>DefaultAlgorithm</code> or <code>DecoratedAlgorithm</code></li>
  <li><code>DefaultAlgorithm</code> and <code>DecoratedAlgorithm</code> both need the properties from <code>Algorithm</code> because those properties are metadata that tells how the algorithms were generated.</li>
  <li><code>DefaultAlgorithm</code> and <code>DecoratedAlgorithm</code> will besides being consumed by other classes (that reads <code>algo</code> and corresponding properties) also be persisted in a database where nested properties might not be desirable.</li>
  </ul>
  <p>When I look at above diagram, I dont feel that things look quite right, for example will the properties of <code>Algorithm</code> be deeply nested, making me have to write awkward code to access the properties.</p>
  <p>To me, possible alternative options could be:</p>
  <ul>
  <li>Extend <code>DefaultAlgorithm</code>, <code>Engine</code> and <code>DecoratedAlgorithm</code> with <code>Algorithm</code>, not caring about &quot;Composition over inheritance&quot;</li>
  <li>Carelessly repeat myself and add the properties to respectively <code>DefaultAlgorithm</code>, <code>Engine</code> and <code>DecoratedAlgorithm</code></li>
  </ul>
  <p>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)</p>