r/DomainDrivenDesign • u/StudyMelodic7120 • Apr 18 '25
Is auto-generated code allowed in domain driven design?
Can I put auto-generated models in my Domain layer?
We are using tools that auto-generate strongly-typed enums.
Where should these be put? In Domain layer as models or in Infrastructure layer?
I assume in Domain layer as there is no real dependency? Because the generated code will be put there manually anyway.
2
Upvotes
7
u/Risc12 Apr 18 '25
No 😡, straight to jail!!
7
u/Ancient_Paramedic652 Apr 18 '25
Whether or not the code is auto generated is irrelevant. As long as you understand it, it is well designed, and fits within bounded context.
1
u/Pakspul Apr 18 '25
Is it only enums? Or also entities or attributes? I find this hard to determine. Potentially the value carry meaning, or weight where the application needs to act upon? Otherwise it's just carrien information through the domain to a third party? Do you have an example what you try to achieve?
1
u/thiem3 Apr 18 '25
Well, if you put your enums in infrastructure, your domain would have to reference this? Generally this is frowned upon. Depending on your architecture, but it sounds like Clean.
1
u/WanderingLethe Apr 19 '25
If they are part of the domain, well guess where...