title: Is it good practice to encapsulate many parameters that are alike into a struct
body: <p>Basically, I have something like the following:</p>
  
  <pre><code>public string SomeDBMethod(string server, string dbName, string userName, string password,...)
  </code></pre>
  
  <p>Is it good practice to refactor it to the following:</p>
  
  <pre><code>public string SomeDbMethod(DBParams parameters, ...)
  </code></pre>
  
  <p>Where DBParams is defined as follows:</p>
  
  <pre><code>public struct DBParams
  {
    string Server {get;set;}
    string DbName {get;set;}
    string UserName {get;set;}
    string Password {get;set;}
  }
  </code></pre>
  
  <p>My point is really to be able to pass around less parameters as I find functions with long parameter lists really quite ugly. </p>
  
  <p>I have also found that there are some limitations to this approach: if SomeDbMethod is to be exposed as a web service method, I cannot use the DBParams struct as a parameter (as far as my understanding on the subject of web services go...which isn't very far).</p>
  
  <p>So, is this too much trouble for little benefit or am I on to something here? </p>