In general, the basic rule that I follow:
If a piece of logic refers to several classes of a domain, put it in the service, otherwise it will be in the domain class.
Without any details about what logic you are dealing with, itβs hard to go much deeper than that, but here are a few more general thoughts:
- As for presentation representations, they are included in libs tags (or possibly services).
- For things that deal with figuring out what to send for viewing and with what type to send it, which is included in the controllers (or possibly services)
- For things that communicate with external objects (i.e., the file system, queues, etc.), they enter services
In general, I tend to make mistakes aside from the fact that I have too many services than something too complicated. In the end, the whole point is what is most important to you, and how you think about the code and how to maintain it.
However, I would like to draw attention to the fact that there is probably a high level of code duplication in what you port. When Grails is built on Groovy and has access to more powerful programming methods like Closures, you can probably clean and simplify most of your code.
cdeszaq
source share