You are on page 1of 11

Group Assignment Topic 2 (The Facebook)

WIA/WIB1002 Data Structure S2, 2022/23

Topic 2: The Facebook


Introduction
It’s been a while since social media took the world by storm. Facebook, Instagram,
Twitter, Snapchat, and many more have become essential tools for us to socialise and
connect with our friends and family. Social media usage constitutes a considerable
portion of our lives. Most of us use it daily: to find long-lost friends, strengthen the bond
between loved ones, get in the loop of our connections’ lives, and so on. The underlying
implementation of this wonderful creation, which enables us to network with people
around the globe, is surprisingly supported by data structures! It is important to
incorporate these data structures into our applications, as they provide implementations
in such a way that data retrieval or storage on social media platforms becomes efficient.

Problem Statement

A thunderstorm brought you back into reality after a nightmare. You got up to wash your
face, as you'd been sweating a lot while sleeping. You looked into the mirror and were
startled to see Mark Zuckerberg, the founder of Facebook, in the reflection. You couldn’t
look for your phone, but there was a calendar and a laptop on the desk. The calendar
shows the year 2004, and a sticky note was pasted on the laptop with the words “Modify
Facemash!” You subconsciously sat on the chair and began drafting and brainstorming
for a brand new idea “TheFacebook”.

1
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23

First things first, you need to use certain data structures for the new application. Without
them, you won’t be able to help people connect with each other, search for new friends,
and get friend recommendations from mutuals on your new application.

This assignment requires you to have a deep understanding of the fundamentals of


programming, which you have already learned in your last semester, as well as
integrate them with your knowledge of data structures in order to prepare you to
develop software in the future.

The hardest problem here is to find the mutual friends between two persons, as the
data structure implemented must be suitable to check for the relationship between one
and another consecutively until two targets are found in the same “friendship line".

2
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23

Basic Features/ Requirements (12 marks)


1. Data Storage (1 mark)
We expect any data created throughout the assignment to be stored in a database of
some form, be it a.txt,.csv, or a DBMS like MySQL, thus it is important to ensure that the
data is not erased completely whenever the program is stopped. Since you have not
learned database management before, you may use.txt to store your data as the
minimum requirement.

Note: Any implementation of DBMS like MySQL will be counted as an extra feature.

2. Login/ Registration & Setup Account (1 mark)


We’ll let you off with this one. You don’t need any data structure for this feature (but if
you do have one that comes to mind, go ahead :)) To be able to use TheFacebook, the
person has to register himself/herself as a user by inputting a Username, Email
Address, Phone Number, Password, and retype password to verify if the passwords
match. After registering, the new user should be able to log in to the system with the
correct credentials (i.e. Email Address OR Phone Number AND Password).

What’s a social media account if you don’t need to include your name, birthday, and
other information? Where's the fun in that? You want other people to see your details,
so you need to set up your account by including some important information, such as
Name, Username, Email Address, Contact Number, Birthday, Age (can be
calculated from birthday), Address (hopefully not the entire address), Gender,
Number of Friends, Hobbies, Jobs, and other relevant and useful information about
yourself using the knowledge you have learnt for Object-Oriented Programming concept
(OOP). All the examples given are merely for your reference and are not mandatory to
implement. However, it must be sufficient to prove the identity of a person.

Note: There are a lot of different approaches which you could use to design the object
creation for User Account. For example, using the knowledge that you have learnt in
Abstraction. By using Abstraction, you could implement Factory Design Pattern, Builder

3
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23
pattern and so on. No marks will be given for wrong implementation of User Account
Object creation.

If you have implemented Factory Design Pattern or other alternatives to create different
types of account, that will be an extra feature as well if you could manage to explain it.

3. Edit Account (1 mark)


You may have just argued with your girlfriend to the brink of a breakup and want to
update your relationship status from “In a relationship” to “It’s complicated”.
TheFacebook allows you to edit the details of your account and save the changes you
make. Note that the changes must be immediately applied instead of something that
only loads after the application is reinitialized.

Besides that, while editing your account, you are required to display the options for
multiple-choice fields and demonstrate which data structure you are using to store the
selections. For instance, while selecting your hobbies, you may display the selections
from an ArrayList; to display your current and previous jobs, you may use a stack to
store the information to show your latest job experiences at the top. You are required to
justify your data structure selection using comments in your code.

4. Add New Friends (1 mark)


Why would you open a social media account if you don’t have any friends? You are
required to design this feature in a way such that a list (or queue, stack, or graph; make
sure you are able to justify your selection of the data structure selected with comments)
of users are recommended to you to add as friends. After a friend accepts your add
request, the application shall update the number of friends you have and add the user to
your friend list. You should also be able to receive friend requests from other users and
store the collection of requests in a suitable data structure.

4
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23
Note: However, before you start working on the connections/relation between users,
make sure you have considered which data structure will help in reducing the
complexity to implement the connection in order to make searching, friend suggestions,
effective and efficient.

5. User Access Control (1 mark)


For your version of TheFacebook, you not only want regular end users to access the
application; you also create an “Admin” role so that the person with that role can
oversee and manage the newly-created application. The administrator can delete users’
accounts, remove inappropriate materials, and do other suitable tasks. You are required
to implement this feature using the Object Oriented Programming (OOP) paradigm.

Optional: if any other roles come to mind, feel free to add them with complete
functionalities (e.g., parental control).

6. Search for Friends (1 mark)


Implement a search feature so that you can attempt to find your long-lost friend, who
may possibly be a user of TheFacebook too. You can search for a user using his/her
name, username, account ID, email address, or contact number.

Not only that, you are required to display the search results in sorted order. For
example, there are four users named Clarice in the database: Clarice Phillip, Clarice
Wong, Clarice Hudson, and Clarice Harrington. Your search query of “Clarice” should
display the search results in this order:

1. Clarice Harrington
2. Clarice Hudson
3. Clarice Phillip
4. Clarice Wong

5
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23

7. View Account (1 mark)


Stalking is creepy, but in 2023, everyone will be doing it on all social media platforms to
look at handsome guys or beautiful girls. Regardless, TheFacebook still needs a view
account feature; otherwise, you wouldn’t know who exactly the person you selected is.
This module will display the information related to the user that you have selected.

Note: You may implement the user’s privacy functionality to allow others to view the
details of the user according to the user’s privacy settings. For example, you may
include a special feature such that the user only wishes his phone number to be viewed
by 2nd-degree connections (refer to Enhanced Networking in Extra Features). This may
be counted as an extra feature.

8. Finding the Mutual Friends between 2 People (2 marks)


By implementing the knowledge you have learned in data structure, show the mutual
friends between two people. If there isn’t any, display an appropriate message.

Tips: You may implement this function by using the shortest path algorithm; however,
you are not limited to using only this method.

9. Traceback Function (2 marks)


As an avid user of social media, you have encountered this event countless times in the
future: you were reading a post or watching a reel when you accidentally hit the back
button or refreshed the page and you really wanted to finish the content. This made you
wonder if anything can be done about it so that this groundbreaking feature can help
other unfortunate users in the future.

You decided to implement this using LinkedList. TheFacebook will keep track of your
user session by storing your interactions with the program, and if you accidentally leave
the content, you are still able to track the history of your interactions and continue where

6
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23
you left off. Your interaction includes the type of content and the content itself (or the
reference to the particular content).

To save on memory, this feature will only store the LinkedList of interactions for that
particular session only, and will not be stored in the database. The LinkedList of
interactions will be emptied when the session ends (the program ends or the user logs
out).

10. Mock Data Creation (1 mark)


To test if your application is working, you are required to populate it with at least 30
normal users and 2 admins. These mock data should not be re-instantiated every time
you start the program, but their state should be stored and retrieved from storage (EG:
You have edited the name for an account, then it must be the one edited after you
restarted the program). You are also required to include relevant data wherever
necessary.

**Warning**

You are NOT ALLOWED to use java.util.HashMap directly, but instead you may create
your own implementation that is similar or identical to HashMap using the knowledge
about generics you have learned to prove your understanding but not copying.

Each of these basic requirements must be in the form of modules (separated into
pages and navigable) rather than a solely sequential program (the program should not
end after execution and can only be ended on command). You can group different
modules the way you want, as long as it makes sense.

7
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23

Extra Features (4 marks)


GUI
Nobody wants to use CLI-based social media, right, Mr. Mark? How about an
interesting, interactable button and search bar? Or maybe you can take a look at your
friend’s beautiful face. By implementing GUI, your program should look intuitive and
easy to use compared to CLI.

Social Media Groups


Usually, youngsters that use social media applications gather up and organise events
together. For example, birthday parties, meet-ups and more! As someone with vision
like you, you knew that the “Group” function would help your app become the next
hottest app in the world.

Implement a “Group” feature that is able to:


1) Let anyone create a common group, the creator will be given the title “Admin” for
that group.
2) Members of the group can invite other users to join the group.
3) The group name will be shown as one of the information on the account page.
4) Posting or sharing content into the group (optional)

Password Hashing // Encryption Algorithm


Would you really use an app if the company actually stored your password in plaintext?
To avoid potential data breaches and mistakes made by TheFacebook in the future, you
decided to enforce strong encryption algorithms before storing passwords in your
database. You may use hashing, Caesar cipher, or any other encryption algorithm.
However, you must be able to justify the algorithm in the presentation.

8
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23

Chats
Why pay for SMS or wait for emails when you can message in real-time over the
Internet for free? The user should be able to choose a friend to initiate a chat with them.
Optional: The user can also add two or more friends into a brand new group chat so
that no one gets left behind!

Fuzzy Search or Any Searching Algorithm


In today's digital age, we are inundated with vast amounts of data and information. As a
result, the task of finding specific information within a large dataset can often be
challenging and time-consuming. This is where we need a more advanced searching
method rather than looking up each and every word to see if they are matching. That
will be a waste of time!! Fuzzy search is a powerful tool that allows users to search for
data that matches a certain pattern or criteria, even if the data is not an exact match. It
is an advanced search technique that uses algorithms to identify and return results that
are similar, but not necessarily identical, to the search query. You may also implement a
string matching algorithm in order to improve the searching. However, you must be able
to justify the algorithm in the presentation.

Database
An application without a database is like a library without books. Use a database to
store all information created on TheFacebook with a reasonable design. You may use
either a SQL or NoSQL database. (You don’t have to adhere to best database practises;
reasonable means working smoothly without causing data storage or retrieval problems)

Data Analysis
In this day and age, information is everything when doing business. You know that in
order to improve your application, you need more data from the users regarding your
own product.

9
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23
Implement data analysis by:
1) Allow your application to generate a summary report. (For instance, total number
of active users, comparison of the number of users by time period [ For example,
last month vs this month ] , total number of users based on categories such as
gender, address, age and more…) (Any that is applicable and proven useful for
data analytics)
2) Generate the report as a .txt file or .csv file in order to carry out further analysis. //
Provide visualisation or an actionable insight based on the summarised
information. For example, drawing graph in the application or display useful
messages such as “The active user this month has decreased, this is possibly
due to the update feature in Patch 2.0 which are: 1) Banning all users who used
inappropriate wordings in their profile…“)

Enhanced Networking
Since you are from the future and you’ve used LinkedIn before, you know about the
Degrees of Connection feature and would like to implement it on TheFacebook. You are
required to label other users accordingly. For example, if you added Harith, he would be
labelled as your “1st” degree connection. If Harith has a friend named Dinesh and you
have not added Dinesh, Dinesh would be your “2nd” degree connection. If Wong is a
friend of Dinesh and not you, Wong would be your “3rd” degree connection.

With this implementation, you are also required to provide friend recommendations to
users with priority (i.e., more 2nd-degree connections are recommended than
3rd-degree connections). Imagine a scenario, A (10 mutuals), B (5), C (6), D (12), E (9),
F (1), G (6) are your 2nd-degree connections, while H (mutual of 3 second-degree
connections), I (5), J (7), K (1), L (2), M (1), N (2) are your 3rd-degree connections, your
recommendations should show some sort of priority to 2nd-degree connections and
also sort them based on the number of mutuals they have. An example would be to
provide recommendations in this order: D, A, E, J, C, G, B, I, F, L, N, K, M.

10
Group Assignment Topic 2 (The Facebook)
WIA/WIB1002 Data Structure S2, 2022/23
Special Note: Apart from the extra features listed in this document, feel free to include
any other relevant extra features that spark your interest!

Tips or Recommendations
1. Try to utilise as many suitable data structures as possible for the features. It is also
important to note that OOP practices are recommended to structure your code base
better.
2. The graph data structure is recommended for anything related to networking.
3. It is recommended to study about Breadth-First-Search (BFS) to search within the
user’s social network.

References and Contact Information


If you have any questions regarding the assignment, please contact Tan Kwan Yang
(kwanyang29@gmail.com please spam if not replied (or just contact ZY he will help
you get to KY)) or Lim Zheng Yu (u2102809@gmail.com, not siswamail ya) and we’ll
try our best to answer your questions as soon as possible :))

11

You might also like