Sunday 15 August 2010

Grails Command Objects - What is the motivation behind them? -



Grails Command Objects - What is the motivation behind them? -

while reading "the definitive guide grails", little confused command objects. seem wrapper around domain classes assist validation functionality available in domain classes via built in constraints , farther via custom validators command object , motivates need it?

the book starts give-and-take on command objects stating

"sometimes particular action doesn’t require involvement of domain class still requires validation of user input."

however, demonstrates declaration of , usage of command object regards album domain class. so, seems whatever command object still closely related domain classes. i'm sure confusion result of lack of understanding , wish seek clarification. thanks.

they seem wrapper around domain classes...

you can utilize command objects way, isn't primary use.

command objects useful when want encapsulate grouping of request parameters , them together. might or might not have domain classes.

for example, have grails app doesn't have domain classes @ , command objects still helpful. imagine grails app service layer receives request web forms or rest requests json body or whatever , grails app going receive requests, validate inputs, maybe math or @ , create rest phone call other backend process might store them in database or generate reports or whatever. in situation that, there lot of reasons might want utilize command objects though no domain classes involved @ all.

don't bound thinking command objects have tied domain classes. are, don't limit thinking of them context. utilize command objects when want relate grouping of request parameters , them.

grails

No comments:

Post a Comment