Skip to main content
22 events
when toggle format what by license comment
Aug 3, 2025 at 9:15 history protected gnat
Jul 23, 2025 at 13:01 answer added JimmyJames timeline score: 1
Jul 22, 2025 at 17:58 answer added radarbob timeline score: 0
Jul 22, 2025 at 17:54 comment added radarbob There seems to be a mindset that "DTO" is sacrosanct, clouding the OP's impulse to apply Single Responsibility principle due to conflating DDD framework and business domain model. Make a proper object of data AND function/behavior. Of course a proper domain object is still that if it has a method returning a DTO - a generic, non business/domain utility thing.
Jul 20, 2025 at 15:22 history edited Bernardo Benini Fantin CC BY-SA 4.0
added 137 characters in body
Jul 20, 2025 at 13:49 answer added VoiceOfUnreason timeline score: 2
Jul 20, 2025 at 1:51 comment added Bernardo Benini Fantin @Basilevs, ohhh, I am sorry for implying that. No, I'd destructure them, because then I'd moving towards a "no mapping" strategy, only giving objects the data they need to be built through their constructors, even if that means a long list of parameters in the constructor. But, to be fair, that's exactly what I was doing in the mapper. So, if that's fine, my main doubt is where I'll place the instantiation.
Jul 19, 2025 at 18:04 comment added Basilevs Related reflection discussion: DDD and Domain Models with a Web Api PUT / POST
Jul 19, 2025 at 17:33 comment added Basilevs DTO object is not just data. It is also a dependency. So if you destructure it before passing tp constructor, it would be fine, but your question seems to imply, that constructor of Domain object would take the whole DTO, making Domain depend on serialization details.
Jul 19, 2025 at 16:13 comment added Rik D In our recent projects we use event sourcing to populate aggregates. No need for mappers or ORM related complexity. Many other benefits too. It’s a big mind shift though.
Jul 19, 2025 at 15:11 comment added Bernardo Benini Fantin @Basilevs, I am sorry, but I didn't get your point. I'd be passing the data I need to the constructor. It would be the constructor that would dictate what data it needs. It's not the case for a factory mathod that maps one thing to the entity, but rather an entity that requires specific data to build itself.
Jul 19, 2025 at 9:51 comment added Basilevs Does not DDD forbids Domain to know about DTOs?
Jul 19, 2025 at 0:33 comment added Bernardo Benini Fantin @JimmyJamessupportsCanada, those are two more classes for each new entity I have, so I want to simplify things. About the login in the constructors, I believe that yes I'll have like a ternary in some cases, to chose between values for a field, but I wouldn't count that as business logic, so I guess I am safe on that matter. But I guess the main reason is that is makes sens for object to "build themselves" through a constructor provided the right parameters.
Jul 19, 2025 at 0:01 comment added Flater [...] plus it increases codebase structure consistency, rather than having to be aware of each individual design decision that was made for each individual scenario.
Jul 18, 2025 at 23:52 comment added Flater 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.
Jul 18, 2025 at 23:49 comment added Flater 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.
Jul 18, 2025 at 20:40 comment added JimmyJames "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.
Jul 18, 2025 at 19:49 comment added Greg Burghardt Thank you for the update, that helps give us some context.
Jul 18, 2025 at 19:45 comment added Bernardo Benini Fantin @GregBurghardt, I added more info. If I was not clear enough, please let me know where I need to improve my question.
Jul 18, 2025 at 19:44 history edited Bernardo Benini Fantin CC BY-SA 4.0
added 1033 characters in body
Jul 18, 2025 at 14:36 review Close votes
Jul 23, 2025 at 3:09
Jul 18, 2025 at 14:10 history asked Bernardo Benini Fantin CC BY-SA 4.0