grails - Issue with class design to model user preferences for different classes -


I'm not sure how to design some classes in my app Basically this is a condition:

  • Each user can have multiple preferences
  • Each preference can be sent to different classes (such as album, movie, book etc.) for the object
  • Preferences values Expressed as a set (for example, etc., etc.)

The problem is that E-users may have priorities on the same object, for example:

  John: score = 5 for Filmmid = Apocalypano Paul: score = 3 for filing = apocalypnove  

And of course I do not want to duplicate the object film in every user.

Therefore, I can create a class named "priority" which holds a digit and is then a target object, such as something:

  user {has many preferences} preference {Iseto user double score} Movie Target Album Target // etc}  

and then only set one goal then I will create an interface for the target class (album, movie etc.):

  interface canBePreferred {hasMany preferences}  

and perform all those operations Vit can. It can work, but it looks very ugly and will require a lot of work to do. Do you have some patterns that I can use this good model?

Cheers, Malone

Preferences have a connection with users and both objects . One or more preferences can be expressed by the user. One or more preferences about the object can be expressed.

To place it in data modeling words, there is 0 to N connection with user preferences, and the object has 0 to N relation with preferences.

Priorities should have a separate class with users and objects.


Comments