6

I searched everywhere and I still can't figure out the difference between a Repository and a DAO.

Suppose we have a Product object, so for me the it would be like this :

class Product {
    public int id;
    public string name;
}

class ProductDAO {

    public void add(Product p) {//saving the product}
    public void delete(int id) {//deleting a product by id}
    public Product update(Product p) {//updating a product}
    public List<Product> listProducts() {//listing all products} 
}

So in a real world project, every Entity should be in a 1-on-1 relation with a DAO class, and from what I've read, a Repository does the same job and can have the same methods I've added in the DAO above for example, except the update method? I don't understand why, is this even true?

Could you please give me a very small example describing the difference ?

Thank you in advance.

Dwix
  • 1,139
  • 3
  • 20
  • 45
  • 1
    Replying to your comment on the answer that was just deleted ("*The [duplicate's] answer didn't help me*") you should have included that in your answer, more specifically what you did not understand about that specific answer. Also, keep in mind that there are 8 answers there, so maybe one of the other answers explain it in a way you can understand better. Edit your question, someone may reopen it. – Vince Jan 03 '16 at 21:14

0 Answers0