1

I'm very new to DDD and sometimes confused by it because many people inside the DDD community tend to have very different approaches when it comes to implementation. I tried to summarize all what I've read so far in a diagram representing control flow of an ASP.NET request. I think I got at least the basics right but there are a couple of points where I'm not sure if the decisions I've made will lead to a change proof and clean software project. The diagram looks like the following:

Architecture Diagram of my project

What I'm not sure about:

  1. I've read that domain models shouldn't be accessed in the Presentation layer and that I should use DTOs instead. I've also read that Repositories shouldn't return DTOs and Transaction Scripts should be avoided for simple CRUD behaviour. So what I came up with for simple CRUD operations is a service layer which is essentially just a Repository Layer but mapping the domain model to DTOs. The purpose of this is to have a complete seperation between Presentation and Domain layer. However it feels a bit akward because the Service Layer is essentially just a duplication of the Repository layer with mappings.

  2. When executing a request I'm mapping between 3 different kinds of objects. ViewModels, DTOs and the domain model. I know that this gives me flexibility and seperation but mapping 3 different types of objects at least once per request seems like a lot of overhead.

  3. I'm not very sure where to put validation. While some people in the DDD community argue it belongs into the domain layer others recommend putting it into the Application Layer or even just the Presentation Layer inside the ViewModels. I haven't come up with a solution for validation needs yet however maybe there's a solution which fits well with the architectural approach I've chosen.
1
  • DDD just like every other architectural approach is just a set of suggestions and guidelines for dealing with complex requirements, it's not a set of rules or dogma. If in doubt, and especially if your requirements aren't complex, then other guidelines that you should consider first are the KISS Principle and the YAGNI Principle Commented May 7, 2020 at 11:14

0