title: SRP, DI and app.config: when to instantiate injecting classes?
body: <p>I'm refactoring a small report-generating application and making it adhere to the SOLID principles, etc. So, all my classes follow SRP with DI and I use app.config for most parameter variations. I'm not using any DI frameworks, yet, but rather creating all the dependency classes at the app entry point. However, that led to a design question, which I'm generalizing here:</p>
  
  <p>I can create my dependencies and main reporter classes like this:</p>
  
  <pre><code>//dependencies    
  var sharedDependency = new SharedDependency();
  
  var whiteColorDependency = new ColorDependency("white");
  var blueColorDependency = new ColorDependency("blue");
  
  var config1Dependency = new MultiDependency("config1");
  var config2Dependency = new MultiDependency("config2");
  ...
  var config12Dependency = new MultiDependency("config12");
  
  
  
  //main logic
  var reporter1 = new Reporter(sharedDependency, whiteColorDependency, config1Dependency);
  var reporter2 = new Reporter(sharedDependency, whiteColorDependency, config2Dependency);
  var reporter3 = new Reporter(sharedDependency, whiteColorDependency, config3Dependency);
  ...
  var reporter10 = new Reporter(sharedDependency, blueColorDependency, config10Dependency);
  var reporter11 = new Reporter(sharedDependency, blueColorDependency, config11Dependency);
  var reporter12 = new Reporter(sharedDependency, blueColorDependency, config12Dependency);
  </code></pre>
  
  <p>or like that:</p>
  
  <pre><code>foreach (var config in configs)
  {
      //dependencies
      var sharedDependency = new SharedDependency();
      var colorDependency = new ColorDependency("color");
      var configDependency = new MultiDependency("config");
  
      //main logic
      var reporter = new Reporter(sharedDependency, colorDependency, configDependency);
      reporter.DoSomething();
  }
  </code></pre>
  
  <p>?</p>
  
  <p>(The "colors" and "config" values are all coming from the app.config file and <strong>not</strong> hard-coded. The above is generalization, as I said, and the real project has more dependencies, dependencies of dependencies, with some more shared than the others.)</p>
  
  <p>The first approach is more efficient, because the CSharedDependency is created only once and CColorDependency only twice. (It's also more readable to me.) The second is fully configuration-driven, though, thus requiring zero maintenance and being fully extensible.</p>
  
  <p>So, which one is the best design?</p>