lundi 26 octobre 2015

Command object only in controller or could it be passed to service layer?

In grails framework I saw the command object pattern but its use is not very clear for me. In addition most of examples given by grails documentation are about domain classes not command objects (maybe to simplify code example).

1 - Command object is something used between view and controller layer and must stay there ?

2 - Or is it a good practice to pass command object to service layer ?

To illustrate point 2 :

class MyController {

    def updateUserPassword (UserPasswordCommand cmd) {
        ...
        myService.updatePassword(cmd)
        ...
    }
}

If point 2 is a bad practice, then how do you pass submitted data to the service layer ? Via domain class ?

Aucun commentaire:

Enregistrer un commentaire