CampusConnect Developer Guide


Acknowledgements


Setting up, getting started

Refer to the guide Setting up and getting started.


Design

Architecture

The Architecture Diagram given above explains the high-level design of the App.

Given below is a quick overview of main components and how they interact with each other.

Main components of the architecture

Main (consisting of classes Main and MainApp) is in charge of the app launch and shut down.

The bulk of the app’s work is done by the following four components:

Commons represents a collection of classes used by multiple other components.

How the architecture components interact with each other

The Sequence Diagram below shows how the components interact with each other for the scenario where the user issues the command delete 1.

Each of the four main components (also shown in the diagram above),

For example, the Logic component defines its API in the Logic.java interface and implements its functionality using the LogicManager.java class which follows the Logic interface. Other components interact with a given component through its interface rather than the concrete class (reason: to prevent outside component’s being coupled to the implementation of a component), as illustrated in the (partial) class diagram below.

The sections below give more details of each component.

UI component

The API of this component is specified in Ui.java

The UI consists of a MainWindow that is made up of parts e.g.CommandBox, ResultDisplay, PersonListPanel, StatusBarFooter etc. All these, including the MainWindow, inherit from the abstract UiPart class which captures the commonalities between classes that represent parts of the visible GUI.

The UI component uses the JavaFx UI framework. The layout of these UI parts are defined in matching .fxml files that are in the src/main/resources/view folder. For example, the layout of the MainWindow is specified in MainWindow.fxml

The UI component,

Logic component

API : Logic.java

Here’s a (partial) class diagram of the Logic component:

The sequence diagram below illustrates the interactions within the Logic component, taking execute("delete 1") API call as an example.

**Note:** The lifeline for `DeleteCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline continues till the end of diagram.

How the Logic component works:

  1. When Logic is called upon to execute a command, it is passed to an CampusConnectParser object which in turn creates a parser that matches the command (e.g., DeleteCommandParser) and uses it to parse the command.
  2. This results in a Command object (more precisely, an object of one of its subclasses e.g., DeleteCommand) which is executed by the LogicManager.
  3. The command can communicate with the Model when it is executed (e.g. to delete a person).
    Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the Model) to achieve.
  4. The result of the command execution is encapsulated as a CommandResult object which is returned back from Logic.

Here are the other classes in Logic (omitted from the class diagram above) that are used for parsing a user command:

How the parsing works:

Finally, the Logic contains the important Command classes. Some command classes from AB3 have been retained:

However, there are new classes implemented for CampusConnect as well:

The structure is simple:

Model component

API : Model.java

The Model component,

**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `CampusConnect`, which `Person` references. This allows `CampusConnect` to only require one `Tag` object per unique tag, instead of each `Person` needing their own `Tag` objects.

Storage component

API : Storage.java

The Storage component,

Common classes

Classes used by multiple components are in the seedu.address.commons package.


Implementation

This section describes some noteworthy details on how certain features are implemented.

Undo/redo feature

Proposed Implementation

The proposed undo/redo mechanism is facilitated by VersionedCampusConnect. It extends CampusConnect with an undo/redo history, stored internally as an history and future. Additionally, it implements the following operations:

These operations are exposed in the Model interface as Model#saveCurrentCampusConnect(), Model#undoCampusConnect() and Model#redoCampusConnect() respectively.

Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.

Step 1. The user launches the application for the first time. The VersionedCampusConnect will be initialized with two stacks.

Step 2. The user executes delete 5 command to delete the 5th person in the CampusConnect. The delete command calls Model#saveCurrentCampusConnect(), causing the modified state of the CampusConnect after the delete 5 command executes to be displayed and the old state of CampusConnect to be saved to the history.

Step 3. The user executes add n/David …​ to add a new person. The add command also calls Model#saveCurrentCampusConnect(), causing the modified state of the CampusConnect after the delete 5 command executes to be displayed and the old state of CampusConnect to be saved to the history.

**Note:** If a command fails its execution, it will call `Model#undoCampusConnect()`, so the CampusConnect state will not be saved into the `history`.

Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the undo command. The undo command will call Model#undoCampusConnect(), which will save the current CampusConnect state into future and pop the latest saved CampusConnect state from the history.

**Note:** If the `history` is empty, then there are no previous CampusConnect states to restore. If so, it will return an error to the user rather than attempting to perform the undo.

The following sequence diagram shows how an undo operation goes through the Logic component:

**Note:** The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

Similarly, how an undo operation goes through the Model component is shown below:

The redo command does the opposite — it calls Model#redoCampusConnect(), which save current state into history and restores the CampusConnect to that state popped from the top of future.

**Note:** If the `future` stack is empty, then there are no undone CampusConnect states to restore. The `redo` command uses `Model#canRedoCampusConnect()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.

Step 5. The user then decides to execute the command list. Commands that do not modify the CampusConnect, such as list, will usually not call Model#saveCurrentCampusConnect(), Model#undoCampusConnect() or Model#redoCampusConnect(). Thus, the history and future remain unchanged.

Step 6. The user executes clear, which calls Model#commitCampusConnect(). All CampusConnectState in the future will be removed. Reason: It no longer makes sense to redo the add n/David …​ command. This is the behavior that most modern desktop applications follow.

The following activity diagram summarizes what happens when a user executes a new command:

Design considerations:

Aspect: How undo & redo executes


Documentation, logging, testing, configuration, dev-ops


Appendix: Requirements

Product scope

Target user profile: NUS undergraduate students

Value proposition:

User stories

Priorities: High (must have) - * * *, Medium (nice to have) - * *, Low (unlikely to have) - *

Priority As a …​ I want to …​ So that I can…​
* * * new user see usage instructions refer to instructions when I forget how to use the App
* * * user add a new contact easily connect with them
* * * user delete a contact remove entries that I no longer need
* * * user find a person by name locate details of persons without having to go through the entire list
* * user update my contacts information always keep an updated version of contact information
* * user undo my last action prevent the accidental deletion of all my contacts
* * user redo my latest undone action prevent the accidental undoing of certain actions
* user with many contacts search contacts by name locate a contact easily
* user add a tag information to contacts easily locate and connect with individuals such as classmates or club members
* student filter contacts by tags such as “group project” or “internship” easily access related contacts
* user with many tags categorize tags into different groups easily organize contacts and locate individuals such as classmates or club members

Use cases

(For all use cases below, the System is CampusConnect and the Actor is the user, unless specified otherwise)

Use case: UC01 - Add a person’s contact

MSS

  1. User requests to add contact.
  2. CampusConnect adds new contact to contact list.
  3. CampusConnect displays success message.

    Use case ends.

Extensions

Use case: UC02 - Delete a person’s contact

MSS

  1. User requests to delete contact.
  2. CampusConnect finds and deletes contact.
  3. CampusConnect displays success message.

    Use case ends.

Extensions

Use case: UC03 - Find a person’s contact

MSS

  1. User requests to find contact.
  2. CampusConnect searches the contact list and displays the details of the contact found.

    Use case ends.

Extensions

Use case: UC04 - Add tags to a contact

Precondition: Contact to add tags to already exists

MSS

  1. User requests to add tags to a contact.
  2. CampusConnect searches the contact list and finds the correct contact.
  3. CampusConnect adds tags to the contact.
  4. CampusConnect displays success message.

    Use case ends.

Extensions

Use case: UC05 - Delete a tag from a contact

Precondition: Contact to delete a tag from already exists

MSS

  1. User requests to delete a specific tag from a contact
  2. CampusConnect searches the contact list and finds the correct contact.
  3. CampusConnect deletes the specific tag from the contact
  4. CampusConnect displays success message

    Use case ends

Extensions

Use case: UC06 - Undo an execution of command Precondition: At least one valid command has been executed by the user.

MSS

  1. User requests to undo the most recent command execution.
  2. CampusConnect reverts the most recent command, restoring the data to its previous state before the command was executed.

    Use case ends

Extensions

Use Case: UC07 - Redo Command Execution

Precondition: The user has previously undone at least one command.

MSS:

  1. The user requests to redo the most recently undone command.
  2. CampusConnect restores the data to the state it was in immediately before the undo.

    Use case ends.

Extensions:

Non-Functional Requirements

  1. Should work on any mainstream OS as long as it has Java 17 or above installed.
  2. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage.
  3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.
  4. The application should respond within two seconds after user input commands.
  5. The application is not required to interact any other online system or applications.
  6. The application should not use offensive and obscene images or visuals.
  7. The record should bot be lost when a system fault occurs.

Glossary


Appendix: Instructions for manual testing

Given below are instructions to test the app manually.

**Note:** These instructions only provide a starting point for testers to work on; testers are expected to do more *exploratory* testing.

Launch and shutdown

  1. Initial launch

    1. Download the jar file and copy into an empty folder

    2. Double-click the jar file Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.

  2. Saving window preferences

    1. Resize the window to an optimum size. Move the window to a different location. Close the window.

    2. Re-launch the app by double-clicking the jar file.
      Expected: The most recent window size and location is retained.

Deleting a person

  1. Deleting a person while all persons are being shown

    1. Prerequisites: List all persons using the list command. Multiple persons in the list.

    2. Test case: delete 1
      Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message.

    3. Test case: delete 0
      Expected: No person is deleted. Error details shown in the status message.

  2. Other incorrect delete commands to try: delete, delete x, ... (where x is larger than the list size)
    Expected: Similar to previous.

Finding a person

  1. Finding a person with tags

    1. Assumption: Pick any 2 tags (or substring of the tags) present in any contact in the contact list. Call these x and y.

    2. Test case: find t/x where x is the substring/tag chosen
      Expected: All contacts with tags containing x will be displayed with a success message.

    3. Test case: find t/x t/y where x and y are the substrings/tags chosen
      Expected: The contact(s) with tags containing x or y will be displayed with a success message.

  2. Finding a person with multiple fields

    1. Prerequisites: There are contacts with tags in the contact list. Add some if this is not the case.

    2. Assumption: Pick any name and tag within the same contact. Call these name x and tag y.

    3. Test case: find n/x t/y where x and y are the name and tag chosen
      Expected: The contact(s) with name containing x and tags containing y will be displayed with a success message.

  3. Other incorrect find commands to try: find, find x (with no prefix)
    Expected: No filtering of contacts will occur and an error message will be displayed.

Undoing the last operation

  1. Undoing an execution that modifies the CampusConnect data

    1. Prerequisites: Perform any operation that modifies the state (all commands except for list and find) to ensure there is an action to undo.

    2. Test case: undo Expected: The last operation is undone, restoring the previous state. The list updates accordingly, and a status message confirms the undo action.

  2. Undo immediately after starting the application

    1. Prerequisites: CampusConnect has been booted and no command has been input yet.
    2. Test case: undo Expected: No undo operation is performed. An error message appears in the status message, indicating there is no action to undo.

Redoing the last operation

  1. Redoing an execution that modifies the CampusConnect data

    1. Prerequisites: Perform any operation that modifies the state (all commands except for list and find) and undo that action.

    2. Test case: redo Expected: The last undone operation is redone, restoring the previous state. The list updates accordingly, and a status message confirms the redo action.

  2. Redo immediately after starting the application
    1. Prerequisites: CampusConnect has been booted and no command has been input yet.

    2. Test case: redo Expected: No redo operation is performed. An error message appears in the status message, indicating there is no action to redo.

  3. Redo when no operation has been undone
    1. Prerequisites: Some commands that affect the state of CampusConnect have been entered but none of them have been redone.

    2. Test case: redo Expected: No redo operation is performed. An error message appears in the status message, indicating there is no action to redo.

Adding a tag

  1. Adding a tag while all tags are being shown

    1. Prerequisites: There are 2 contacts in the list. First contact on the list has tag CS2100, second contact has tags floortball and friends.

    2. Test case: addtag 1 t/CS2040S
      Expected: The first contact now has 2 tags CS2100 and CS2040S. The tag list is updated accordingly.

    3. Test case: addtag 2 t/homie t/homie Expected: The second contact now has 3 tags floortball, friends and homie. The tag list is updated accordingly.

    4. With the following test cases:

      1. Test case: addtag 0 t/volleyball
      2. Test case: addtag 3 t/homie
      3. Test case: addtag 2
        Expected: No new tags are added. Error message is shown.

Deleting a tag from a person

  1. Deleting a tag.

    1. Prerequisites: There are contacts with tags in the contact list. Add some if this is not the case.

    2. Assumption: Pick any contact with at least one tag. Let i be the index (one-based) of this contact and x be the name of the tag.

    3. Test case: deltag i t/x where i is the index and x is the tag chosen
      Expected: The tag x will be deleted from person i and the tag will also disappear from the Tag List. A success message will be displayed.

  2. Other incorrect delete tag commands to try: deltag, deltag M t/x (where M is larger than the list size or smaller than 0), deltag 1 x
    Expected: No deleting of tags will occur and an error message will be displayed.

Categorizing a tag

  1. Categorizing an existing tag

    1. Prerequisites: Ensure that the tag CS2103 exists and is under a category other than Academics (Gold).

    2. Test case: cattag t/CS2103 acads </br> Expected: Success message is shown. All occurrences of the tag CS2103 in the person list on the bottom left and tag list on the bottom right are set to Academics category. Colour of tag CS2103 set to Gold.

  2. Attempting to categorize a non-existent tag

    1. Prerequisites: Ensure that tag A does not exist yet.

    2. Test case: cattag t/A activity </br> Expected: Error message “Tag not found: [A]” is shown, indicating that tag A does not exist.

  3. Attempting to categorize to an invalid category

    1. Prerequisites: Ensure that tag CS2103 is still present.

    2. Test case: cattag t/CS2103 foo </br> Expected: Error message “Invalid category: foo” is shown.

  4. Attempting to categorize an invalid tag to an invalid category

    1. Prerequisites: Ensure that tag A does not exist yet.

    2. Test case: cattag t/A foo </br> Expected: Error message “Invalid category: foo” is shown. Message for invalid tag is not shown for this case.


Appendix: Planned enhancements

Team size: 5

  1. Change the font color for tags: Currently, the font color for GENERAL tags is grey, making them less noticeable. We plan to use a higher-contrast font color to make tags more prominent and easier to read.
  2. Allow adding overseas phone number: The app currently supports only Singaporean phone number. We aim to expand functionality to include valid international numbers, complete with country codes.
  3. Allow certain special characters: We currently only allow alphanumeric characters and whitespaces. We plan to support additional characters, such as hyphens, to better accommodate real-world naming conventions.
  4. Make duplicate contact error message more specific: The current error message for duplicate contacts, “This person already exists in CampusConnect,” is too general. We plan to enhance it by specifying the name of the existing contact that duplicates the one the user is attempting to add.
  5. Make find n/, find p/ and find e/ throw an error while find t/ finds all users with not tags.
  6. Make the result display box slightly larger to accommodate longer error messages.

Appendix: Future features

Below is a list of features that we feel would further enhance the user experience.

Feature Description
Clustering of tags Group tags of the same categories together in the UI’s display of the tags list.
Pin contacts Keep selected contacts constantly shown at the top of the contacts list.
Customize category colors Change the colors of the categories to the user’s preference.
Multiple numbers per contact Allow more than one number per contact to accommodate multiple contact numbers.
Custom fields for contacts Add custom fields to the contacts added.
Custom shortcut commands Add custom shortcut commands to streamline actions within the application.
Delete tag from all contacts Remove a specific tag from all contacts at once.
Dark mode Include a dark mode theme for easier viewing in low light conditions.
Copy contact information Enable copying of contact information to reduce errors from manual copying.
Export contacts Provide an option to export contact information for easier sharing.

Appendix: Effort

Our goal was to improve AB3 in terms of contact organisation, finding and tagging to allow for greater functionality and flexibility.

Our first major change was to modify the find command to accept any field as a parameter and allow multiple parameters. This was a moderate effort that required us to change how the FindCommand class worked by creating new predicate classes and processing the logic for that as well, which was aided by the given predicate classes that we used as a template, but it was not trivial.

Our next major change was the undo and redo commands, which were quite extensive to implement. We had to create the VersionedCampusConnect (a variation on the VersionedAddressBook) and resolve serious issues related to the undo and redo state, such as logic to process when the undo and redo commands failed and whether non-state affecting commands (like find) would affect the undo and redo result. Overall, this was quite difficult.

Finally, our last major change was the tag management and categorisation system, which was more difficult as the undo and redo. We added a tag management component and several commands, different types of tags, and a tag list component in the UI. Figuring out how to dynamically update the tags and the tag list in the GUI required a restructuring of our GUI files (under the ui folder) and we had faced many issues with the tag categorisation system. All in all, implementing this system was not easy but it did provide better tag customisation and control than AB3.

Most commands implemented used the given Command classes as a reference, but modified them to adapt the respective execute() methods for the command.

On top of all these, we had also modified the GUI, which required us to familiarise and work through the quirks of JavaFX.