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.

Required fields*

14
  • 1
    "My goal is to eliminate the Adapters and Presenters and make the DTOs build themselves" I'm unclear as to why this is your goal. There are a number of things that can only be done in a constructor but doing a lot of logic in one is a bad idea in my experience and often just moving things out of the constructor can cause awkwardness and problems to vanish. Commented Jul 18, 2025 at 20:40
  • 1
    In my opinion, the basis of the posted question is missing the mark. Mapping is not something that operates on a single object, it's a transferral from one structure to another. When you say that an object should construct itself - what should it construct itself from? What if there are multiple sources? What if the construction takes a significant amount of effort relative to the complexity of the target type in and of itself? This is effectively arguing that how to construct an object is the same responsibility as that of the object itself. That is not always a given, only sometimes. Commented Jul 18, 2025 at 23:49
  • 1
    Sometimes the mapping is so trivial that it doesn't matter that you add it into the class. But that is not a given for every use case. So this becomes an argument of exactly how complex something has to be for it to warrant being in a separate mapper. And realistically, a lot of senior devs I know find it easier to simply create the mapper as a consistent pattern across their codebase, rather than having to judge every single case and argue about where it falls on the spectrum of making a separate mapper or not. Sure, maybe there's some overkill but it saves a bunch of time arguing. Commented Jul 18, 2025 at 23:52
  • 1
    [...] plus it increases codebase structure consistency, rather than having to be aware of each individual design decision that was made for each individual scenario. Commented Jul 19, 2025 at 0:01
  • 1
    Does not DDD forbids Domain to know about DTOs? Commented Jul 19, 2025 at 9:51