Name: Ionescu Matei-Ștefan
Group: 323CAb
POO TV implements the core backend mechanics of platforms like HBO GO and Netflix using OOP concepts. The application receives a list of actions from a file in json format and generates a new json file with the required output for each action.
This project builds upon the Homework #2 - POO TV and represents an improved version with more features. In this README I will be taking about the new features and their implementation. For more information about the project check the README from the first version of the application available at https://github.com/Matei77/OOP-POO-TV.
The core of the application is still represented by the PlatformEngine
class.
This class has been designed using the Singleton Design Pattern to allow
only one instantiation of the class and acts as a database to hold information
about the movies and users on the platform, as well as the current user, the
movies the current user can see and the current page the user is located in.
Each page has specific actions that can only happen on that page. In my implementation each page represents a class that implements the Page interface and is created using the Factory Design Pattern. The PageFactory is instantiated using the Singleton Design Pattern to save memory by allowing only one instance of the PageFactory. Each page class overrides the required methods from the Page interface. The default output for each method in the interface is the error message.
When a new admin action is executed, all observers are notified. Admin actions
are adding and deleting movies to and from the database. The AdminActions
represents the observable class, and the User
class is the observer.
The AdminActions
class will store the list of observers and will notify them
when an action is executed. The notifyObserver
method from the User
class will then decide if the user should receive the notification given by the
admin.
A new feature has been implemented, the back button, and it is using the
Command Design Pattern. Changing the page is now executed using the
ChangePageInvoker
which hold a history of successful change page commands
and implements the execute
and undo
methods that goes to the next page,
respectively goes back to the previous page.
For each user the platform holds information about his credentials, his
purchased, watched, liked and rated movies, the type of his account,
the number of free premium movies he has available, his tokens and his balance.
In this version of the application the notification system was introduced
and users now receive notifications from the platform. The Notification
class was implemented for this reason.
For each movie the platform holds information about the name, the year, the
duration, the genres, the actors, the countries banned in, the number of
likes and the ratings. Movies now have an improved rating system that allows
changing the user's rating. This is implemented using the Rating
class.
When the runEngine
method is called movies and users databases will be
updated with the information contained in the input json file and the actions
received will be executed. The output will be shown in a new json file called
results.out.
The following new user actions were introduced:
-
subscribe
This action allows a user to subscribe to a genre.
When the subscribe command is given, the
subscribe()
method will be called, and it will check if the movie currently seeing has the selected genre and if the user was not already subscribed to it. If this is the case, the user will now receive notifications when movies from that genre are added. -
back
This action allows a user to go to the previous page.
When the back command is given, the
ChangePageInvoker.undo()
method will be called, and it will go to the previous page if possible. Otherwise, it will output an error.
The following admin actions were introduced:
-
add
This action allows admins to add a movie to the database at any time.
When the add command is given, the
AdminActions.addMovieToDatabase()
method will be called, and it will add the movie given in input to the database. Users that subscribed to any of the genres of the movie will be notified about the new movie. -
delete
This action allows admins to delete a movie from the database at any time.
When the delete command is given, the
AdminActions.deleteMovieFromDatabase()
method will be called, and it will delete the movie given in input from the database. Users that have purchased the movie will be notified about the deleted movie and reimbursed.
The AdminActions
class is implemented using the Observer Design Pattern.
Admin actions are observable by the observers (the users).
At the end of the execution of all actions, if there is a premium user
logged-in they will be notified about a movie they should watch. The movie
recommendation system is implemented in the giveRecommendation()
method
from the User
class. And find a movie the user would probably enjoy by
analyzing the user's liked genres and the most popular movies on the platform.
The most popular movie that the user hasn't watched yet is recommended. The
LikedGenre
class was implemented to allow this new feature of the platform.