title: One instance of Report per instance of Simulation: use a singleton?
body: <p>I have written code that runs many different simulations, each in its own <code>Simulation</code> object. To extract results from a <code>Simulation</code>, we first have to ask <code>Simulation</code> to create an instance of <code>Report</code> (as one of <code>Simulation</code>'s children). </p>
  
  <p>Even though a <code>Simulation</code> can contain many instances <code>Report</code>, the creation process is quite expensive, so if there already is a <code>Report</code> in that particular <code>Simulation</code>, I want to re-use it rather than create a new one. </p>
  
  <p>The <code>Report</code> instances are accessed from many different classes in my code. I'd like to avoid replicating code that first checks whether a <code>Report</code> already exists in that particular <code>Simulation</code>, then based on that either get the existing one or make a new one. </p>
  
  <p>I really only want there to be one instance of <code>Report</code> per <code>Simulation</code> -- kind of like a singleton...</p>
  
  <p>I see two avenues:</p>
  
  <ol>
  <li><p>Making a kind of "singleton" report class that allows the creation of no more than one <code>Report</code> per <code>Simulation</code>. Is this possible?</p></li>
  <li><p>Making a <code>SpecialSimulation</code> class that extends <code>Simulation</code>, and in <code>SpecialSimulation</code> include a singleton that contains a <code>Report</code>. Is this overkill?</p></li>
  </ol>
  
  <p><code>Simulation</code> and <code>Report</code> are from a commercial Java API that we have a license for; I can't modify their source code. </p>
  
  <p>Doing my best to learn the ropes of Java and OOP...</p>