title: Creating a factory method for creating new SqlConnection objects
body: <p><a href="https://stackoverflow.com/questions/11687146/is-this-defensive-code-or-are-there-possibilities-that-it-could-encouter-problem">FOLLOW UP TO MARC GRAVELLS SUGGESTION IN THIS QUESTION</a></p>
  
  <p>I now have something like this repeated several times in my code:</p>
  
  <pre><code>using (var conn = CreateConnection())
  using (var dataCommand = conn.CreateCommand()) 
  {
          conn.Open();
          [...]                        
  } 
  </code></pre>
  
  <p>Is the following correct for the factory method <code>CreateConnection()</code>? Or will it be error prone? (note: I'm only ever going to call it from a <code>using</code> directive)</p>
  
  <pre><code>SqlConnection CreateConnection()
  {
      SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["IMS"].ConnectionString);
      return conn;
  }
  </code></pre>
  
  <p>Or would there be a case for amending this method and having the <code>Open</code> in it as well?</p>