Skip to content

alexandrubuzea/VideosDB

Repository files navigation

Copyright: Buzea Alexandru-Mihai-Iulian 321CAb

OOP Homework - VideosDB

     The subject of this homework is to create a simple model of a database
in order to store informations about movies, serials (shows), actors, users
and the relationships between there entities.

     Using OOP concepts and standards, I created some classes in order to
describe the existing objects:

     -> Actor class
     I used this class in order to store the information about an actor
(name, awards, description, filmography etc). I also created some useful methods
(such as getters for all fields, which are private #encapsulation, and get
number of awards, a method which is useful for some queries and recommendations).

     -> User class
     I used this class in order to store informations about an user (username,
history, favorite video list etc). I also created some useful methods (getters
and get number of ratings method) which are helpful when analyzing queries about
users.

     -> Video class
     I used this class in order to store informations about a video (only the
common details between a video and a serial; I also created these two classes
separately) and I also created some common methods (to be overriden) such as
getDuration() and hasRating() - methods that helps me to find out what is the
duration of a video (which is calculated in different ways) and if some video
has at least one rating (which is also calculated in different ways).

     -> Movie class (extends Video)
     I used this class in order to store some particular information about a
movie (a single set of ratings, for example) and to override some useful methods
described above.

     -> Serial class (extends Video)
     I used this class in order to store some particular information about a
movie (for example, multiple sets of ratings - one for each season) and to override
some methods described above.

     -> Database class
     I used this class in order to store all information about all existing
entities and instances (actors, users, videos). In order to model the database,
I used the singleton pattern (lazy instantiation, to be more specific - I
created a private constructor in order to create only one instance of the
Database class).

     -> Action, Command, Query and Recommendation classes.
     These classes contain only static methods and are used in order to perform
a set of actions, which can be commands (user views a video / user adds a video
in the favorite list / user gives a rating to a video), queries (there are multiple
types of queries, for users, videos and actors, which are described in the javadoc
- most of them use filters for year, keywords or genre, or are using all kinds
of sorting criteria, such as number of ratings, average rating, popularity and
so on) and recommendations (these are a special type of queries which are destined
to recommend one unseen video to a user who wants to get a recommendation).

     Some other OOP aspects I implemented or used:
     - I used java.util.AbstractMap.SimpleEntry<K, V> in order to store arrays of
pairs (this is very effective especially because it is inefficient to calculate
the average rating each time an object is the subject of a comparison), which I
sorted using lambda expressions.
     - I used some basic concepts of functional programming in order to shorten
the code and make it easier to be understood, such as map(), filter() (forEach,
removeIf etc), stream() and lambda expressions. It really made a huge difference
in improving code's quality.
     - I used LinkedHashMap<> in order to store all required key-value pairs for
maximum efficience (minimum query time - O(1)).
     - I implemented some static methods in utils package (determining the mean
value of a double array and getting an arraylist with all genres as Strings).
     - All in all, I applied some very important concepts, such as polymorphism,
encapsulation, inheritance and used an important design pattern (which is
singleton pattern used in order to implement database).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published