Open reignman5 opened 3 years ago
Although it's been a bit since I shot that video I believe I state something like, "The majority of dml should take place in a service layer 85-90%". There aren't a ton of situations that warrant dml operations outside of the service layer but every once in a while the domain layer warrants its own dml operations. If it is necessary to commit in the domain layer then it's fine to do it, just make sure it's truly object specific behavior and it's warranted to place that logic there.
Thanks for the quick answer. So it would not be an "anti-pattern" to call a service layer from the domain layer? Or would I call the domain class of the object I want to create?
Sorry, I must've missed this, no it is definitely not an anti-pattern to do that. You can certainly call a service layer from the domain if necessary.
You said in one video that we should put dmls in the service layer. Does this mean, that if we have a trigger that executes on afterInsert and creates a new record (different object), this logic should go into a service layer?