Is there any performance benefits to using Command objects to validate constraints over using Domain objects to validate constraints
Meaning if i intercept incoming params and place then in a command object and call cmd.hasErrors() , before binding it to the object and trying a obj.save()
and allowing the object constraints to do the validation
I’ve never noticed any performance benefit – in fact there may be a slight performance hit doing this. Your command object will do it’s validation and binding and your domain object will still do it’s validation and binding as well. That’s just a guess and if true it’s probably a relatively small hit.
My basic strategy has been if I’m doing form input for strictly a single class I just use the domain. If there is either no domain required (like for a login) or multiple domains (like an author and a book) on the same form use a command object.