title: When should I use params Object[] versus Dictionary<String, Object>?
body: <p>I'm defining an API as an interface which we'll call <code>IFoo</code> and I want to define a method <code>Bar()</code></p>
  
  <p>This method <code>Bar()</code> will take one required argument and then some arbitrary number of other arguments.  The interpretation of these other arguments will be up to implementors of <code>IFoo</code></p>
  
  <p>For this scenario is it more appropriate to define my interface using <code>params</code> or using <code>Dictionary&lt;String, Object&gt;</code> e.g.</p>
  
  <pre><code>public interface IFoo
  {
     bool Bar(String id, params Object[] params);
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>public interface IFoo
  {
     bool Bar(String id, Dictionary&lt;String, Object&gt; params);
  }
  </code></pre>
  
  <p>It seems like the former is easier for users to invoke but the latter is more explicit in its intentions since with the former you'd have to specify the parameters in a specific order for the implementation to interpret them properly while with the latter you are essentially doing named parameters.</p>
  
  <p>So questions:</p>
  
  <ul>
  <li>Which form should I be using (and why?) - is one of these considered best practice over another?</li>
  <li>Are there specific advantages to one style versus the other that I should be aware of?  Is one of these considered a code smell?</li>
  <li>Is there an alternative pattern that would achieve the same thing in a different/nicer way?</li>
  </ul>
  
  <p>For the record I am aware of <a href="http://msdn.microsoft.com/en-us/library/dd264739.aspx" rel="nofollow">named parameters</a> in .Net 4.0 but this code needs to be compilable on .Net 3.5 so can't use any .Net 4.0+ functionality</p>
  
  <h3>Edit</h3>
  
  <p>Just to add more detail on what my <code>IFoo</code> and <code>Bar()</code> methods are actually representing because someone asked.</p>
  
  <p><code>IFoo</code> represents some storage subsystem and <code>Bar()</code> is actually a create operation.  Depending on the storage subsystem <code>Bar()</code> could require no parameters other than the ID or it could require many parameters.</p>
  
  <h3>Edit 2</h3>
  
  <p>So in response to @Kirk Woll's comment and @Fernando's answers here's more information.</p>
  
  <p>I will likely never invoke <code>IFoo.Bar()</code> myself, this interface is part of an open source framework.  3rd party devs will be implementing <code>IFoo</code> and end users will be invoking specific instances of it, the point of having <code>IFoo</code> at all is to make it easier for users to migrate their applications between storage subsystems because they can code to interfaces rather than specific implementations as far as humanly possible.</p>
  
  <p>In the simplest case the underlying storage subsystem only has one form of store so no parameters will be required other then the ID.  In the complex case the storage subsystem may allow multiple types of store and each type of store may permit arbitrarily complex set of configuration parameters e.g. index size, persistence, transaction behavior, indexing strategy, security and ACL considerations etc.</p>
  
  <p>I agree with @Fernando that maybe something more polymorphic may make sense, maybe polymorphism combined with generics and type restrictions may be best e.g.</p>
  
  <pre><code>public interface IFoo
  {
    bool Bar&lt;T&gt;(T parameters) where T : IBarConfig;
  }
  
  public interface IBarConfig
  {
    String ID { get; set; }
  }
  </code></pre>
  
  <p>Then with an implementation like so:</p>
  
  <pre><code>public class MyFoo
  {
    bool Bar&lt;T&gt;(T config) where T : MyBarConfig
    {
      //Implementation
    }
  }
  
  public class MyBarConfig : IBarConfig
  {
    public String ID { get; set; }
  
    public long IndexSegmentSize { get; set; }
  
    //Etc...
  }
  </code></pre>
  
  <p>This is off the top of my head so not sure if it is actually legal to define <code>Bar()</code> in <code>MyFoo</code> with a different type restriction then the interface it implements?</p>