title: Choosing specific vs generic methods
body: <p>Which would be a better design for a public interface:</p>
  
  <pre><code>WriteValue(DeviceValueType.MachineName,"micks machine");
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>WriteMachineName("Micks machine");
  </code></pre>
  
  <p>If you use type 1 then you just need one such generic interface and you can write to any number of <em>DeviceValueTypes</em> just by adding items to the enum.</p>
  
  <p>The second type is more specific in that it will write only a value to specific type denoted by its method name. But these methods have a great advantage with respect to type safety.</p>
  
  <p>For eg: Lets consider another type</p>
  
  <pre><code>WriteValue(DeviceValueType.SleepDelay,"25");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>WriteSleepDelay(25);
  </code></pre>
  
  <p>Note that here, type 2 has an advantage because I can specify the type expected. If I were to use type 1 then I will have to cast the value to int and then throw an exception  if the value is not in the expected range. If I had to pass complex types, this becomes even more difficult.</p>
  
  <p>So in summary:</p>
  
  <p>Type 1: Generic. The interface will need to expose only one method. No type safety for parameters.
  Type 2: Specific. The interface will require as many methods as there are types. Type safe.</p>
  
  <p>What is the generally suggested methodology to solve this problem?</p>
  
  <p>I am using C# but I believe this problem to be non language specific.</p>