Domain driven design repository implementation in infrastructure layer

APL

I got a question on dependencies of DDD layered architecture. If the Repository implementation is in the infrastructure layer, that means that infrastructure layer has a dependency on domain layer because Entities will be referenced in the Repository implementation.

On the other side, the Domain layer can have references to the infrastructure layer if infrastructure services are used in the domain.

Wouldn't this create a cyclic reference?

GraemeMiller

Look at the onion architecture it shows a good setup for a DDD solution. (Look at my comment below - use verticial slices instead if you can - cost of onion doesn't seem justified after using for years)

Basically all domain model and interfaces for domain services are considered core. Layers depend only on layers above them that are closer to the core. Their actual implementation is handled by infrastructure.

Domain project shouldn't reference infrastructure project. If domain needs to use something it should be defined as an interface within domain and implemented in the infrastructure project.

Ultimately your interfaces are what defines your application. The logic of how that gets implemented is externalised. So I'd expect you to have assemblies with Domain Models and domain services, a front end (e.g. MVC etc) and then an infrastructure assembly that implements things like NHibernate for providing data etc.

You can see various samples that implement the architecture in the various parts of the linked article. The simplest one is here

You can see questions related to it here

The main benefit is that it is largely the infrastructural concerns that will change the most often. New data layer technologies, new file storage, etc. Also, your core domain should be reasonably stable as it isn't implementing anything just defining by contract(interfaces) what it requires. By putting the implementation concerns in one location you minimise the amount of changes that will be required across your assemblies.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Domain Driven Design: infrastructure concern or domain concern?

From Dev

Domain Driven Design: infrastructure concern or domain concern?

From Dev

Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

From Dev

Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

From Dev

Separate application service for command / query in CQRS implementation in Domain Driven Design?

From Dev

Layers in Domain Driven Design

From Dev

Domain Driven Design - Domain or Security

From Dev

DDD - Domain Service with infrastructure implementation

From Dev

Access Control in Domain Driven Design

From Dev

Domain Driven Design and batch processing

From Dev

Implementing Domain Driven Design Cost

From Dev

Implementing Domain Driven Design Cost

From Dev

Domain Driven Design Bounded Context Domain Objects

From Dev

Domain Driven Design. Entity type design

From Dev

DDD Auditing? Domain Layer or Repository Layer?

From Dev

Implementing Paging and Sorting with Domain Driven Design

From Dev

Implementing Domain-Driven Design and Transactions

From Dev

Domain Driven Design in Node.js Application

From Dev

Fetching associated aggregates in Domain driven Design

From Dev

Domain Driven Design - CQRS + ES usage

From Dev

Where is the call to persistence in the domain driven design

From Dev

Implementing Domain Driven Design Book Confusion

From Dev

Domain Driven Design (DDD) and database generated reports

From Dev

Domain-Driven-Design Entities and Value Objects

From Dev

Proper way to get aggregates in Domain Driven Design

From Dev

Domain Driven Design Auto Incremented Entity Key

From Dev

Fetching associated aggregates in Domain driven Design

From Dev

Where to find Domain Driven Design consultants?

From Dev

How to add scheduled jobs in domain driven design

Related Related

  1. 1

    Domain Driven Design: infrastructure concern or domain concern?

  2. 2

    Domain Driven Design: infrastructure concern or domain concern?

  3. 3

    Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

  4. 4

    Domain Driven Design: Can Infrastructure or Repositories use Domain objects?

  5. 5

    Separate application service for command / query in CQRS implementation in Domain Driven Design?

  6. 6

    Layers in Domain Driven Design

  7. 7

    Domain Driven Design - Domain or Security

  8. 8

    DDD - Domain Service with infrastructure implementation

  9. 9

    Access Control in Domain Driven Design

  10. 10

    Domain Driven Design and batch processing

  11. 11

    Implementing Domain Driven Design Cost

  12. 12

    Implementing Domain Driven Design Cost

  13. 13

    Domain Driven Design Bounded Context Domain Objects

  14. 14

    Domain Driven Design. Entity type design

  15. 15

    DDD Auditing? Domain Layer or Repository Layer?

  16. 16

    Implementing Paging and Sorting with Domain Driven Design

  17. 17

    Implementing Domain-Driven Design and Transactions

  18. 18

    Domain Driven Design in Node.js Application

  19. 19

    Fetching associated aggregates in Domain driven Design

  20. 20

    Domain Driven Design - CQRS + ES usage

  21. 21

    Where is the call to persistence in the domain driven design

  22. 22

    Implementing Domain Driven Design Book Confusion

  23. 23

    Domain Driven Design (DDD) and database generated reports

  24. 24

    Domain-Driven-Design Entities and Value Objects

  25. 25

    Proper way to get aggregates in Domain Driven Design

  26. 26

    Domain Driven Design Auto Incremented Entity Key

  27. 27

    Fetching associated aggregates in Domain driven Design

  28. 28

    Where to find Domain Driven Design consultants?

  29. 29

    How to add scheduled jobs in domain driven design

HotTag

Archive