PROJECT: Makan Book


Overview

Makan Book is a restaurant guide and application for diners in National University of Singapore (NUS). It allows users to write and view reviews for restaurants within NUS. Additionally, Users are able to interact with one another to create a more enjoyable experience.

Summary of contributions

  • Major Enhancement: Addition of friendship feature*

    • What it does: Users are able to add other users as friends, accept any existing friend requests as well as delete friends or friend requests.

    • Justification: This feature improves the product as users can now have a storage (such as phone number and email address) of the personal particulars of their friends.

  • Other enhancements: Addition of groups functionality (not my feature)*

    • What it does: Even though this is not my feature, a lot of code was implemented for groups. Users are able to create groups, add other users to groups, delete group requests that they have received and leave groups that they are part of.

    • Justification: This feature improves the functionality of the product as it allows for users to be grouped together much like creating groups in the real world (like Facebook or whatsapp).

    • Highlights: Groups feature was used by 3 other members/features - to split debt among members of the group, add all members of a group to a jio and find free dates among all members of the group.

  • Code contributed: [here]

  • Other contributions:

Contributions to the User Guide

Given below are sections I contributed to the User Guide.

Adding friends: addFriend

A User will send a friend request to another User who will then have to accept the friend request.
Format: addFriend u/USERNAME

Examples:

  • addFriend u/meena567

Accept friend request: acceptFriend

A User can accept a friend request of another User so that the pair of them can become friends.
Format: acceptFriend u/USERNAME

Examples:

  • acceptFriend u/meena567

Delete friend request: deleteFriendRequest

A User can delete friend request of another User whom they might not know.
Format: deleteFriendRequest u/USERNAME

Examples:

  • deleteFriendRequest u/meena567

Delete friend: deleteFriend

A User can delete friend whom they may no longer want to be friends with.
Format: deleteFriend u/USERNAME

Examples:

  • deleteFriend u/meena567

List friend requests: listFriendRequests

A User can list friend requests that they have received. Only the party that did not initiate the friend request will receive the friend request
Format: listFriendRequests

List friends: listFriends

A User can list their friends.
Format: listFriends

Adding groups: addGroup

A User will create a group by specifying the group name.
Format: addGroup g/GROUPNAME

  • Every group will automatically add the user creating the group into its list of accepted Users.

Examples:

  • addGroup g/CS2103

Adding members: addMembers

A User already in the group can add members to a particular group by specifying the group name and the usernames of the users they wish to add to that group.
Format: addMembers g/GROUPNAME [Users u/USERNAMES]…​

Examples:

  • addMembers g/CS2103 u/chelchia u/evanmok2401 u/katenhy u/yewwoei

Accepting group requests: acceptGroup

A User can accept the invitation to join a group.
Format: acceptGroup g/GROUPNAME

Examples:

  • acceptGroup g/CS2103

Deleting group requests: deleteGroupRequest

A User can choose to delete the group request should they not want to join the group.
Format: deleteGroupRequest g/GROUPNAME

Examples:

  • deleteGroupRequest g/CS2103

Deleting groups: deleteGroup

A User can leave a group and they will be removed from the group.
Format: deleteGroup g/GROUPNAME

Examples:

  • deleteGroup g/CS2103

List group requests: listGroupRequests

A User can list group requests that they have received.
Format: listGroupRequests

List groups: listGroups

A User can list groups that they are a part of.
Format: listGroups

Contributions to the Developer Guide

Given below are sections I contributed to the Developer Guide.

Adding, accepting and deleting friends and friend requests

Current Implementation for Friendships

Friendships can have two statuses - ACCEPTED and PENDING. User A can send a friend request to User B which would then store a friendship with User A as PENDING under User B alone. User B can choose to accept or delete the friend request. If User chooses to delete the friend request, the PENDING friendship under User B will be deleted. If User B chooses to accept the friend request, the friendship status will be changed from PENDING to ACCEPTED for User B and an identical friendship will be added to User A, the one who initiated the friendship.

AddFriendCommandSequenceDiagram

Now moving on to deletion of friends. Assuming that two Users C and D are friends with each other, and User C deletes his or her friendship with User D. This would delete the friendship stored under both User C and User D even if User D did not initiate the deletion of friendship. It is also possible to list the existing list of friends (ACCEPTED) and friend requests (PENDING).

The Friendship class itself stores 'me' (currently logged in User), 'friendUser' (other party in the friendship), 'friendshipStatus' (status of the friendship) and 'initiatedBy' (which party the friendship was initiated by). There is a restriction such that the 'initiatedBy' must be either 'me' or 'friendUser'. A friendship is immutable once created. Friendships are stored as an XML element under users.xml with the four attributes mentioned above.

Why the current implementation for Friendships

The PENDING friendships are only stored under the User who did not initiate the friendship. This so that when the listFriendRequests command is called so as to allow the User to accept and delete the friend requests accordingly, it only makes sense for the User to see the friendships that they wish to accept or delete (i.e. friendships not initiated by them). Thus, friend requests are only stored under the User who did not initiate the friendship.

There are two separate lists for friendships - one for friend requests and one for friends. This is to aid the listing functions and avoid confusion by simplifying the friendships stored under User.

Exceptions and why they are thrown

There are several exceptions thrown for the friendship commands. An exception is thrown for all friendship commands should there be no User logged in currently. Specifically for the adding of friends (i.e. sending friend requests) a User cannot send a request to himself. Moreover, if the User has previously sent a request which has yet to be accepted by the other User, the initiating User cannot send another request. However, if the recipient User has deleted the friend request, then the initiating User is able to send a new friend request. A blocking feature is to be made in v2.0. Moreover, a User cannot send a friend request to another User with whom they are already friends with.

When it comes to accepting friendships, there are several exceptions thrown too. If the User tries to accept a friend request not in their list of friend requests an exception is thrown. Similarly, an exception is thrown if the User tries to delete a friend request not in their list of friend requests or a friend who is not in their list of friends.

Alternatives considered for Friendships

For a while, I considered storing all friendships (both friend requests and friends) in the same list. However, I decided against this as this made things potentially confusing especially for a new developer coming in to retrieve only friends or friend requests.

XML storage

Initially, I faced a problem balancing making the code more OOP (to preserve the true spirit of software engineering) and storing friendships as an XML element. XML elements only take in Strings and not objects. However to store friendships, the elements stored include Users ('friendUser', 'me' and 'initiatedBy'). Thus, I considered sacrificing the OOP-nature of Friendships as proposed above and instead merely storing usernames as strings for the User.

To get around this problem, a hashmap mapping Username to the User is passed to the class doing the XML storage and loading of Friendships. Thus, OOP is not sacrificed as User is still the data type of the attributes stored in Friendship and Friendships can be created from the XML element with the aid of the hashmap.

Initially, I considered asking the initiating User to enter all the information about the other User to add them as a friend. This is so that I would be able to construct the User from the the information provided. However, this would be too inconvenient for the User and thus the hashmap mentioned before was used.

Adding friends

  1. Add a valid user as a friend

    1. Prerequisites: User is logged in as meena567. meena567 is not already friends and has not sent a friend request to katespades

      1. Test case: addFriend u/katespades
        Expected: Friend request sent to: katespades

  2. Send a friend request to a user multiple times

    1. Prerequisites: User is logged in as meena567. Have already sent a friend request previously to katespades which has not been accepted or deleted by katespades

      1. Test case: addFriend u/katespades
        Expected: You have already sent friend request to this User

  3. Send a friend request to a user who has sent a friend request to you previously

    1. Prerequisites: User is logged in as meena567. meena567 has a friend request from katespades which has not been accepted yet by meena567.

      1. Test case: addFriend u/katespades
        Expected: You have that user’s friend request. Please accept that request instead of adding them as a friend.

  4. Send a friend request to a user who is already a friend

    1. Prerequisites: User is logged in as meena567. meena567 is already friends with katespades.

      1. Test case: addFriend u/katespades
        Expected: You are already friends with this user.

Accepting friends

  1. Accepting a valid friend request

    1. Prerequisites: User is logged in as meena567. meena567 has a friend request from katespades

      1. Test case: acceptFriend u/katespades
        Expected: Successfully accepted friend request of: katespades

  2. Accepting an invalid friend request

    1. Prerequisites: User is logged in as meena567. meena567 does not have a friend request from katespades

      1. Test case: acceptFriend u/katespades
        Expected: Sorry, that user is not in your friend requests' list.

Deleting friend requests

  1. Deleting a valid friend request

    1. Prerequisites: User is logged in as meena567. meena567 has a friend request from katespades

      1. Test case: deleteFriendRequest u/katespades
        Expected: Successfully deleted friend request of user : katespades

  2. Deleting an invalid friend request

    1. Prerequisites: User is logged in as meena567. meena567 does not have a friend request from katespades

      1. Test case: deleteFriendRequest u/katespades
        Expected: Sorry, that User did not send you a friend request.

Deleting friends

  1. Deleting a valid friend

    1. Prerequisites: User is logged in as meena567. meena567 is friends with katespades

      1. Test case: deleteFriend u/katespades
        Expected: Successfully deleted friend with username: katespades

  2. Deleting an invalid friend request

    1. Prerequisites: User is logged in as meena567. meena567 is not friends with katespades

      1. Test case: deleteFriend u/katespades
        Expected: Sorry, the friend that you want to delete does not exist in your list of friends

Adding groups

  1. Adding a valid group

    1. Prerequisites: User is logged in as meena567 and wants to add a group with name CS2103. CS2103 is not the name of any other group in Makan Book.

      1. Test case: addGroup g/CS2103
        Expected: Group created: CS2103

  2. Adding an invalid group

    1. Prerequisites: User is logged in as meena567 and wants to add a group with name CS2103. However, there exists another group with name CS2103.

      1. Test case: addGroup u/CS2103
        Expected: Sorry, a group with that name exists. Please choose a different group name.

Accepting groups

  1. Accepting a valid group request

    1. Prerequisites: User is logged in as meena567. meena567 has a group request from CS2103

      1. Test case: acceptGroup g/CS2103
        Expected: Successfully accepted group request of: CS2103

  2. Accepting an invalid group request

    1. Prerequisites: User is logged in as meena567. meena567 does not have a group request from CS2103

      1. Test case: acceptGroup g/CS2103
        Expected: Sorry, that group is not in your group requests' list.

Adding members to groups

  1. Adding all valid members

    1. Prerequisites: User is logged in as meena567 and meena567 is part of group CS2103. meena567 wants to add users who are not part of the group and have previously received group request.

      1. Test case: addMembers g/CS2103 u/katespades u/thejrlinguist
        Expected: Members added to group: CS2103=[katespades, thejrlinguist]

  2. Adding some members who are part of the group

    1. Prerequisites: User is logged in as meena567 and meena567 is part of group CS2103. meena567 wants to add users thejrlinguist and katespades to the group. However, thejrlinguist is already part of the group but katespades is not.

      1. Test case: addMembers g/CS2103 u/katespades u/thejrlinguist
        Expected: Sorry, username to be added is in the group. No users were added to the group.

        1. Even though katespades is not a part of the group, the command will not add any members to the group as thejrlinguist is already inside the group.

  3. Adding users who already have a group request

    1. Prerequisites: User is logged in as meena567 and meena567 is part of group CS2103. meena567 wants to add katespades to the group. However, katespades already has a request to the group.

      1. Test case: addMembers g/CS2103 u/katespades
        Expected: Sorry, User already has a request for that group.

Deleting group requests

  1. Deleting a valid group request

    1. Prerequisites: User is logged in as meena567. meena567 has a group request from CS2103

      1. Test case: deleteGroupRequest g/CS2103
        Expected: Successfully deleted group request of group : CS2103

  2. Deleting an invalid group request

    1. Prerequisites: User is logged in as meena567. meena567 does not have a group request from CS2103

      1. Test case: deleteGroupRequest g/CS2103
        Expected: Sorry, you do not have that group request

Deleting group

  1. Deleting a valid group

    1. Prerequisites: User is logged in as meena567. meena567 is part of CS2103 group

      1. Test case: deleteGroup g/CS2103
        Expected: Successfully deleted group with name: CS2103

  2. Deleting an invalid group

    1. Prerequisites: User is logged in as meena567. meena567 is not in CS2103 group

      1. Test case: deleteGroup g/CS2103
        Expected: Sorry, the group that you want to delete does not exist in your list of groups