title: Repository Pattern Standardization of methods
body: <p>All I am trying to find out the correct definition of the repository pattern.</p>
  
  <p>My original understanding was this (extremely dumbed down)</p>
  
  <ul>
  <li>Separate your Business Objects from your Data Objects</li>
  <li>Standardize access methods in data access layer.</li>
  </ul>
  
  <p>I have really seen 2 different implementation, and there are no formal examples online, the ones i have seen are tucked away in books.</p>
  
  <p><strong>Implementation 1 :</strong></p>
  
  <pre><code>public Interface IRepository&lt;T&gt;{
        List&lt;T&gt; GetAll();
        void Create(T p);
        void Update(T p);
  }
  
  
  public interface IProductRepository: IRepository&lt;Product&gt; {
        //Extension methods if needed
         List&lt;Product&gt; GetProductsByCustomerID();
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Implementation 2 :</strong></p>
  
  <pre><code>public interface IProductRepository {
        List&lt;Product&gt; GetAllProducts();
        void CreateProduct(Product p);
        void UpdateProduct(Product p);
        List&lt;Product&gt; GetProductsByCustomerID();
  }
  </code></pre>
  
  <p>Notice the first is generic Get/Update/GetAll, etc, the second is more of what I would define "DAO" like.  </p>
  
  <p>Both share an extraction from your data entities.  Which I like, but i can do the same with a simple DAO.  However the second piece standardize access operations I see value in, if you implement this enterprise wide people would easily know the set of access methods for your repository.  </p>
  
  <p>Am I wrong to assume that the standardization of access to data is an integral piece of this pattern ?   If both are correct why would one choose to do implementation 2? </p>
  
  <p><a href="http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/10/08/the-repository-pattern.aspx" rel="noreferrer">Rhino</a> has a good article on implementation 1, and of course MS has a vague <a href="http://msdn.microsoft.com/en-us/library/ee413961.aspx" rel="noreferrer">definition</a> and an example of implementation 2 is <a href="http://weblogs.asp.net/fredriknormen/archive/2008/04/24/what-purpose-does-the-repository-pattern-have.aspx" rel="noreferrer">here</a>.</p>