title: How do I design a Data Access Layer appropriately?
body: <p>I have the following Data Access Layer (DAL).  I was wondering if it's set up correctly, or if I need to improve it?</p>
  
  <pre><code>public class User 
  {
  
  }
  
  //Persistence methods
  static class UserDataAccess
  {
     UsersDAL udal = // Choose SQL or FileSystem DAL impl.
  
  
     InsertUser(User u)
     {
        // Custom logic , is 'u' valid etc. 
  
        udal.Insert(u);
     }
  }
  
  abstract class UsersDAL
  {    
     GetUserByID();
     InsertUser(u);
     ...
  }
  
  // implementaitons of DAL
  
  static class UsersSQLStore : UsersDAL
  {
  
  }
  
  static class UsersFileSystemStore : UsersDAL
  {
  
  }
  </code></pre>
  
  <p>I separated the storage layer from the User class to access methods collection which further call any custom DAL.</p>
  
  <p>Is use of <code>static</code> in DAL implementation correct?</p>
  
  <p>Please suggest corrections or ways I can make this better. I don't have a lot of experience with writing code in layers.</p>