I have a little question about MVC:
For example if I have a model “Video” and the application allow the user to add/remove favourite videos (handling the favourites in a database for example).
What is the correct approach for implementing that?
- The class Video has isFavourite() / addToFavourites() methods. When called the Model access to the database adapter and updates the proper value.
- Both Video an VideosManager have isFavourite() / addToFavourites() calls. When some method calls video.addToFavourites(), the Video model calls to VideoManager.addToFavourites(this)
- Only the VideoManager implements isFavourite(Video) / addToFavourites(Video) methods. When someone wants to change the favourites calls directly to the VideoManager.
A Video can be a favorite for a specific User. Giving the class Video isFavorite()/addToFavorite() methods get’s this relation wrong. So options 1 and 2 are not viable.
This seems to favor option 3. But I would like to place a side note. What is a VideoManager? The User should be responsible for managing her favorite videos, doesn’t she?
So in my opinion there should be a model for Video’s and Users. A View for Videos would have the option for a user to signal that it is a favorite. This action calls a controller that adds/removes the video from the User’s set of favorites.