title: Strategy Design pattern with IOC containers - Ninject specifically
body: <p>I have a class which is going to need to use the strategy design pattern. At run time I am required to switch different algorithms in and out to see the effects on the performance of the application.</p>
  
  <p>The class in question currently takes four parameters in the constructor, each representing an algorithm.</p>
  
  <p>How using Ninject (or a generalised approach) could I still use IOC but use the strategy pattern?</p>
  
  <p>The current limitation is that my kernel (container) is aware of each algorithm interface, but that can only be bound to one concrete class. The only way around this I can see at the moment is pass in all eight algorithms at construction, but use different interfaces, but this seems totally uncessary. I wouldn't do this if I was not using an IOC container, so there must be some way around this.</p>
  
  <p>Code example:</p>
  
  <pre><code>class MyModule : NinjectModule 
  {
      public override void Load() 
      {
          Bind&lt;Person&gt;().ToSelf();
          Bind&lt;IAlgorithm&gt;().To&lt;TestAlgorithm&gt;();
          Bind&lt;IAlgorithm&gt;().To&lt;ProductionAlgorithm&gt;();
      }
  }
  </code></pre>
  
  <p>Person needs to make use of both algorithms so I can switch at run time. But only TestAlgorithm is bound, as it's the first one in the container.</p>