Grails Command Objects - What is the motivation behind them? -
While reading "The Definition Guide to Greaves", I'm a bit of Command Object I'm confused. They take a cover around the domain classes to help with validity, but it is already made up of obstacles in the domain classes and is already available through custom Valiaaut. Then what does the command object actually do and why do we need it?
Discussing book command objects, it explains that
"Sometimes a particular action does not require participation of the domain class, but still user The recognition of the input is required. "
However, it refers to the declaration and use of a command object in relation to a album
domain class, so that It seems that a command object is still from domain classes It is very closely related. I am convinced that my illusion is completely the result of my lack of understanding and that's why I want to find some explanation. Thank you.
They take a cover around the domain classes ...
You can use command objects, but this is not their primary use.
Command objects are useful, when you encapsulate a group of request parameters and want to do something with them. There may be something like this or there can be nothing with domain classes
For example, you might have a Grails app that does not contain any domain class and command objects can be really useful Imagine a Grails app that is just a service layer that receives requests from a web form or receives REST requests with a JSON body or that the Grails app is going to receive those requests, input Validate, maybe do some math or anything and then make a concession call on some other backend process which can store them in a database or generate reports or in whatever situation, there are so many reasons. You want to use the command object, however no domain classes are included in it
Command objects must be associated with the domain class, do not force them to think Please. Sometimes these are, but do not limit your thinking of those references. Use the command object when you want to add a group of request parameters together and do something with them.
Comments
Post a Comment