Suppose i have a Cat domain as shown below.
class Cat{
String name
Integer age
}
Now i want to add a new feature that will assign tags to cats.
Now i see two options to achieve this.
Option 1
add a property to the Cat domain
class Cat{
String name
Integer age
String tag
}
Option 2
Create a new table
class CatTagAssignment{
Cat cat
String tag
static mapping = {
id composite: ['cat', 'tag']
}
}
I am trying to understand which is a better approach or which one should i prefer when i want to add a new feature? I appreciate it if you can offer pros and cons of both approach and whether one approach is always preferable to the other. I appreciate your help! Thanks!