I have some methods that are common across a few of my domain classes. I want to reduce the amount of replicated code and two solutions came to mind:
1) Put the common methods in a baseDomain class and inherit the methods from it in my domains
2) Put the common methods in a commonDomainMethodService which I can import into my domains
I am thinking I should leave inheritance alone unless the domains share common properties, but I'm not sure. Is one of these methods more beneficial than the other? Is one more in line with Grails best practices?
For example a method that compares two domain instances based on a parameter:
int compareInstances(instance, otherInstance, propertyName){
return //some logic to compare the instances based on the type of property
}