vendredi 14 juillet 2017

Method in model, service, or elsewhere?

I have a User model. A user can be reviewed. Thus I also have a Review model that represents a review of the user. With the review a rating of the user is saved.

Let's say I am to create a method that fetches the rating of the user based on all reviews of him, for example the getRating() method. Would I create this method on the User model? Or would you create for example a review-managing service class and include the method in that class?

Adding the getRating() method to the User model feels like a logical thing to do, but on the other hand things might get out of hand at one point, leaving me with a huge User model class.

Aucun commentaire:

Enregistrer un commentaire