Câu hỏi phỏng vấn DDD
Câu hỏi

What is the difference betwe...

Câu trả lời

In Domain-Driven Design (DDD), the Data Access Object (DAO) and Repository patterns serve distinct purposes, although they both deal with data access. Here are the key differences between them:

Data Access Object (DAO)

  1. Purpose: The DAO pattern provides an abstract interface to some type of database or other persistence mechanism. It encapsulates the details of the data access logic, ensuring that the service layer remains unaware of the underlying data access strategy[2][3].
  2. Level of Abstraction: DAOs operate at a lower level of abstraction compared to Repositories. They are often table-centric and closely tied to the database schema[4].
  3. Granularity: DAOs can be very granular, often leading to a proliferation of data access classes, each corresponding to a specific table or entity[2].
  4. Operations: DAOs typically include CRUD (Create, Read, Update, Delete) operations and may contain methods like update, delete, and find[3].
  5. Flexibility: DAOs are more flexible and generic, making them suitable for various types of data sources and persistence mechanisms[5].

Repository

  1. Purpose: The Repository pattern is more abstract and is specifically tailored for DDD. It acts as an in-memory collection of domain objects, providing a collection-oriented interface to access domain entities[2][3].
  2. Level of Abstraction: Repositories operate at a higher level of abstraction, focusing on domain concepts rather than database details. They manage domain aggregates and ensure that the domain logic remains untainted by persistence concerns[2][4].
  3. Domain-Centric: Repositories are domain-centric and speak the language of the domain. They are de...
senior

senior

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between Domain Objects, POCO, Services, Repositories and Entities?

senior

What is Core Domain, Supporting Subdomain, and Generic Subdomain in DDD?

middle

What is the differences between Strategic Patterns and Tactical Patterns?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào