title: Is this a perfect problem for the factory pattern?
body: <p>I want to design the file storage part of my application with some flexibility, so one can store files in either S3 or on the web server's hard drive.</p>
  
  <p>I also want this to be flexible on a per user basis, so in their user settings they can choose if they want their files stored in S3 or on the servers file system.</p>
  
  <p>I am thinking of something like this:</p>
  
  <pre><code>IFileStorage fs = FileStorageFactory.Instance(userSettings);
  </code></pre>
  
  <p>Then I would have a method that looks like:</p>
  
  <pre><code>public static IFileStorage Instance(UserSettings setting)
  {
       if(setting == UserSettings.S3)
           return new S3FileStorage();
  }
  </code></pre>
  
  <p>Does this make sense?  (I'm a c# programmer but I will be doing this in Java)</p>
  
  <p>I am using Spring, but I don't think DI will be used here since the implementation changes on a per user basis.</p>