I have a User model that can contain 1-n UserGroup models, each of which contains information about user relationships with a specific group (for example, if they are group administrators, when they joined the group, etc.).
I would like to provide some helper methods, such as isGroupUser () and isGroupAdmin (), which work on the whole set of UserGroup models stored in the user model. Now these methods are in the User model, but they are about twice the size of the model.
Does it make sense to interpret code that runs on UserGroup models in your class? So, the User model will contain one instance of this "interface" class, which will also contain UserGroup models for work. I feel this keeps the related code nicely separated, and the User model becomes overwhelming.
Also, is there a design template for this kind of thing? It seems that a class that works with a collection of other objects will be quite common.
Thank you for understanding!
source
share