Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • So the Repository implementation would belong to an outer layer (e.g. infrastructure layer)? And regarding the application services/use case orchestration, I'd like to go into details, do you happen to have a reference I could study? Or a tip on what I should look for? Commented Feb 3, 2019 at 18:14
  • Yes, the repository implementation goes in the infrastructure layer. As for a reference on application services, here's some sample code from Vaughn Vernon's book on DDD: github.com/VaughnVernon/IDDD_Samples Commented Feb 3, 2019 at 18:42
  • Regarding DDD's Repository, you're wrong in two ways: 1) often, a Repository will contain complex queries which indeed do contain business logic (if you ever developed a complex business app, you would know that); 2) The Repository implementation belongs within the Domain layer, never the Infrastructure layer (if it was put in Infrastructure, this would create a dependency in the reverse direction, upwards the stack of layers, breaking the fundamental rule of layering, ie, that dependencies only go from higher layers to lower layers). Commented Jul 18, 2019 at 19:09
  • 4
    @Rogério: I work on very large enterprise applications and no, you don't want to put business logic in your queries. Doing so locks your business logic into a particular database implementation and makes it very hard to switch to a different vendor. This goes beyond DDD, you never want to couple your business logic to an external product. Also I don't understand your argument about layering, the infrastructure layer is the outermost layer and the domain layer does not depend on it. Commented Jul 21, 2019 at 3:15
  • 1
    I've never seen an example where the domain layer depends on infrastructure, not in the DDD book nor in any other architectural pattern. Check the link I posted earlier and you'll see that Vaughn Vernon clearly separates the infrastructure into a "port/adapter" package, which is very similar to onion architecture. The underlying principle here is separation of concerns, and DDD isn't somehow exempt from that. Commented Jul 23, 2019 at 4:05