user3767551
user3767551

Reputation: 69

Where to Keep the Repository implementations in DDD?

1) As per Domain Driven Design, the Domain Layer should have only the Repository Interface and Implementation should not be part of Domain Layer - Please advice me if my understanding is wrong?

2) If the Repository implementations should not be a part of Domain Layer, then where should i keep the Repository implementations (in Infrastructure ?)

3) Is the following directory structure is suggestible if i want to have my design flow like this: (i am using DAO not ORM)

Controller <---dto---> Domain Service <----dto---> RepositoryImpl <---> DAOImpl

Directory structure

+ Infrastructure
      +--- Logging
      +--- Caching

+ Applicaton
      +---- Service1Controller

+ DomainLayer
      +---- Service1Impl
      +---- Service2Impl

+ DataAccessLayer
      +----Repositories
               +----------Service1Repositories
               +----------Service2Repositories
      +----DAO
               +----------Service1DAO
               +----------Service2DAO

4) Repository can be a part of Data Access Layer?

5) DDD is an Architecture or Design ? If it is architecture then what is the difference between DDD and Onion Architecture?

Upvotes: 2

Views: 1276

Answers (1)

Rafał Łużyński
Rafał Łużyński

Reputation: 7312

  1. As of statement:

    A. High-level modules should not depend on low-level modules. Both should depend on abstractions.

    B. Abstractions should not depend upon details. Details should depend upon abstractions.

    Your understanding is ok. You couple your domain layer with interface, not implementation.

  2. Yes, infrastructure is the best place for it.

  3. It should do fine.

  4. Implementation of repository, yes.

  5. Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and terminology for making design decisions that focus and accelerate software projects dealing with complicated domains. Architecture is something totally different. You can use any architecture with DDD.

Upvotes: 2

Related Questions