As I've been using Grails more and more, I find myself writing code in multiple controllers that really seems like it should be part of a domain class. Sometimes, this domain code contains a call to a service class. For example, I recently wrote a domain method that looked something like this:
class Purchase {
// Injected
def paymentService
String captureTransactionId
Boolean captured
// ...
def capture() {
captureTransactionId = paymentService.capturePurchase( this )
captured = captureTransactionId != null
}
I don't feel outright dirty writing this code, but I haven't made a study of best design practices in Grails, so I wanted to get some opinions.