Skip to content

Latest commit

 

History

History
560 lines (360 loc) · 23.4 KB

DeveloperGuide.adoc

File metadata and controls

560 lines (360 loc) · 23.4 KB

TutorAid - Developer Guide

1. Setting up

Refer to the guide here.

2. Design

2.1. Architecture

ArchitectureDiagram
Figure 1. Architecture Diagram

The Architecture Diagram given above explains the high-level design of the App. Given below is a quick overview of each component.

💡
The .puml files used to create diagrams in this document can be found in the diagrams folder. Refer to the Using PlantUML guide to learn how to create and edit diagrams.

Main has two classes called Main and MainApp. It is responsible for,

  • At app launch: Initializes the components in the correct sequence, and connects them up with each other.

  • At shut down: Shuts down the components and invokes cleanup method where necessary.

Commons represents a collection of classes used by multiple other components. The following class plays an important role at the architecture level:

  • LogsCenter : Used by many classes to write log messages to the App’s log file.

The rest of the App consists of four components.

  • UI: The UI of the App.

  • Logic: The command executor.

  • Model: Holds the data of the App in-memory.

  • Storage: Reads data from, and writes data to, the hard disk.

Each of the four components

  • Defines its API in an interface with the same name as the Component.

  • Exposes its functionality using a {Component Name}Manager class.

For example, the Logic component (see the class diagram given below) defines it’s API in the Logic.java interface and exposes its functionality using the LogicManager.java class.

LogicClassDiagram
Figure 2. Class Diagram of the Logic Component

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.

ArchitectureSequenceDiagram
Figure 3. Component interactions for delete 1 command

The sections below give more details of each component.

2.2. UI component

UiClassDiagram
Figure 4. Structure of the UI Component

API : 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.

The UI component uses 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,

  • Executes user commands using the Logic component.

  • Listens for changes to Model data so that the UI can be updated with the modified data.

2.3. Logic component

LogicClassDiagram
Figure 5. Structure of the Logic Component

API : Logic.java

  1. Logic uses the AddressBookParser class to parse the user command.

  2. This results in a Command object which is executed by the LogicManager.

  3. The command execution can affect the Model (e.g. adding a person).

  4. The result of the command execution is encapsulated as a CommandResult object which is passed back to the Ui.

  5. In addition, the CommandResult object can also instruct the Ui to perform certain actions, such as displaying help to the user.

Given below is the Sequence Diagram for interactions within the Logic component for the execute("delete 1") API call.

DeleteSequenceDiagram
Figure 6. Interactions Inside the Logic Component for the delete 1 Command
ℹ️
The lifeline for DeleteCommandParser should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

2.4. Model component

ModelClassDiagram
Figure 7. Structure of the Model Component

API : Model.java

The Model,

  • stores a UserPref object that represents the user’s preferences.

  • stores the Address Book data.

  • exposes an unmodifiable ObservableList<Person> that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.

  • does not depend on any of the other three components.

ℹ️
As a more OOP model, we can store a Tag list in Address Book, which Person can reference. This would allow Address Book to only require one Tag object per unique Tag, instead of each Person needing their own Tag object. An example of how such a model may look like is given below.

BetterModelClassDiagram

2.5. Storage component

StorageClassDiagram
Figure 8. Structure of the Storage Component

API : Storage.java

The Storage component,

  • can save UserPref objects in json format and read it back.

  • can save the Address Book data in json format and read it back.

2.6. Common classes

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

3. Implementation

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

3.1. Earnings Feature

3.1.1. Add Earnings

The add_earnings command allows for tutors to add their earnings into TutorAid.

The format for the add_earnings command is as follows:

add_earnings d/<DATE> c/<CLASSID> amt/<AMOUNT>

Overview

The add claim add_earnings mechanism is facilitated by AddEarningsCommand and AddEarningsCommandParser, taking in the following input from the user: Date, ClassId, Amount, which will construct Earnings objects.

AddEarningsSequenceDiagram
Figure 9. Add Earnings Command Sequence Diagram

The AddEarningsCommand implements Parser with the following operation:

  • AddEarningsCommandParser#parse() - This operation will take in a String input from the user and create individual objects based on the prefixes d/, c/ and amt/. The String value after the respective prefixes will create the respective objects. A validation check will be done to ensure that the strings that are entered by the user is entered correctly. If any of the strings entered are invalid, an error will be shown to the user to enter the correct format of the respectives objects.

    • date would use ParserUtil#parseDate() to ensure that the date typed by the user is in the correct format of DD/MM/YYYY.

    • classId would use ParserUtil#parseClassId() to ensure that the class id typed in by the user is in the correct format.

    • amount would use ParserUtil#parseAmount() to ensure that the amount entered by the user is in the correct format with 2 decimal places to represent the cents.

  • After validation of the individual objects, an Earnings object would be created with the parameters date, classId and amount.

  • AddEarningsCommandParser would then return a AddEarningsCommand object with the parameter, Earnings object.

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

AddEarningsActivityDiagram

Example Scenerio

  • Step 1: The user enters add_earnings d/04/08/2019 c/CS1231 amt/50.00 to add an earning for teaching classes. This adds an Earnings object that the user has earned by teaching a CS1231 class on 4th August 2019. The user has earned $50.00.

  • Step 2: LogicManager would use AddressBookParser#parse() to parse input from the user.

  • Step 3: AddressBookParser would match the command word given by the user with the correct command. In this example, the given command is add_earnings, thus, AddEarningsCommandParser object would be created with the user’s input.

  • Step 4: AddEarningsCommandParser performs a validation check on each of the respective objects through AddEarningsCommandParser#parse(). In this case, it would use ParserUtil#parseDate(), ParserUtil#parseClassId() and ParserUtil#parseAmount(). It would then return a AddEarningsCommand object with an Earnings object.

  • Step 5: LogicManager would execute AddEarningsCommand#execute. In this particular method, the Earnings object will be check with the rest of the prior Earnings object, to ensure that there is no duplicate Earnings object. If there are no similar Earnings object with the same parameters created previously, it would then be added into the earnings list.

  • Step 6: AddEarningsCommand would then return a CommandResult to LogicManager, which would show the user that the new Earnings object have been successfully added.

3.2. Notes Features

3.2.1. Add Notes

The addnote command allows for tutors to add their notes into TutorAid.

The format for the addnote command is as follows:

addnote mod/<MODULE_CODE> c/<CONTENT>

Overview

The add claim add_earnings mechanism is facilitated by AddNotesCommand and AddNotesCommandParser, taking in the following input from the user: Module_Code, Content, which will construct Notes objects.

Add Note Command Sequence Diagram

##diagram to be added

The AddNotesCommand implements Parser with the following operation:

  • AddNotesCommandParser#parse() - This operation will take in a String input from the user and create individual objects based on the prefixes mod/ and c/. The String value after the respective prefixes will create the respective objects. A validation check will be done to ensure that the strings that are entered by the user is entered correctly. If any of the strings entered are invalid, an error will be shown to the user to enter the correct format of the respectives objects.

    • code would use ParserUtil#parseModuleCode() to ensure that the module code typed by the user is in the correct format of CSXXXX.

    • content would use ParserUtil#parseContent() to ensure that the content typed in by the user is in not empty.

  • After validation of the individual objects, an Notes object would be created with the parameters code and content.

  • AddNotesCommandParser would then return a AddNotesCommand object with the parameter, Notes object.

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

##diagram to be added

Example Scenerio

  • Step 1: The user enters addnote mod/CS2103T c/Update Project to add an note for teaching classes. This adds an Notes object that the user has added to record what needs to be done for the class.

  • Step 2: LogicManager would use AddressBookParser#parse() to parse input from the user.

  • Step 3: AddressBookParser would match the command word given by the user with the correct command. In this example, the given command is addnote, thus, AddNotesCommandParser object would be created with the user’s input.

  • Step 4: AddNotesCommandParser performs a validation check on each of the respective objects through AddNotesCommandParser#parse(). In this case, it would use ParserUtil#parseModuleCode() and ParserUtil#parseContent(). It would then return a AddNotesCommand object with an Notes object.

  • Step 5: LogicManager would execute AddNotesCommand#execute. In this particular method, the Notes object will be check with the rest of the prior Notes object, to ensure that there is no duplicate Notes object. If there are no similar Notes object with the same parameters created previously, it would then be added into the notes list.

  • Step 6: AddNotesCommand would then return a CommandResult to LogicManager, which would show the user that the new Notes object have been successfully added.

3.3. [Proposed] Undo/Redo feature

3.3.1. Proposed Implementation

The undo/redo mechanism is facilitated by VersionedAddressBook. It extends AddressBook with an undo/redo history, stored internally as an addressBookStateList and currentStatePointer. Additionally, it implements the following operations:

  • VersionedAddressBook#commit() — Saves the current address book state in its history.

  • VersionedAddressBook#undo() — Restores the previous address book state from its history.

  • VersionedAddressBook#redo() — Restores a previously undone address book state from its history.

These operations are exposed in the Model interface as Model#commitAddressBook(), Model#undoAddressBook() and Model#redoAddressBook() 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 VersionedAddressBook will be initialized with the initial address book state, and the currentStatePointer pointing to that single address book state.

UndoRedoState0

Step 2. The user executes delete 5 command to delete the 5th person in the address book. The delete command calls Model#commitAddressBook(), causing the modified state of the address book after the delete 5 command executes to be saved in the addressBookStateList, and the currentStatePointer is shifted to the newly inserted address book state.

UndoRedoState1

Step 3. The user executes add n/David …​ to add a new person. The add command also calls Model#commitAddressBook(), causing another modified address book state to be saved into the addressBookStateList.

UndoRedoState2
ℹ️
If a command fails its execution, it will not call Model#commitAddressBook(), so the address book state will not be saved into the addressBookStateList.

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#undoAddressBook(), which will shift the currentStatePointer once to the left, pointing it to the previous address book state, and restores the address book to that state.

UndoRedoState3
ℹ️
If the currentStatePointer is at index 0, pointing to the initial address book state, then there are no previous address book states to restore. The undo command uses Model#canUndoAddressBook() to check if this is the case. If so, it will return an error to the user rather than attempting to perform the undo.

The following sequence diagram shows how the undo operation works:

UndoSequenceDiagram
ℹ️
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.

The redo command does the opposite — it calls Model#redoAddressBook(), which shifts the currentStatePointer once to the right, pointing to the previously undone state, and restores the address book to that state.

ℹ️
If the currentStatePointer is at index addressBookStateList.size() - 1, pointing to the latest address book state, then there are no undone address book states to restore. The redo command uses Model#canRedoAddressBook() 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 address book, such as list, will usually not call Model#commitAddressBook(), Model#undoAddressBook() or Model#redoAddressBook(). Thus, the addressBookStateList remains unchanged.

UndoRedoState4

Step 6. The user executes clear, which calls Model#commitAddressBook(). Since the currentStatePointer is not pointing at the end of the addressBookStateList, all address book states after the currentStatePointer will be purged. We designed it this way because it no longer makes sense to redo the add n/David …​ command. This is the behavior that most modern desktop applications follow.

UndoRedoState5

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

CommitActivityDiagram

3.3.2. Design Considerations

Aspect: How undo & redo executes
  • Alternative 1 (current choice): Saves the entire address book.

    • Pros: Easy to implement.

    • Cons: May have performance issues in terms of memory usage.

  • Alternative 2: Individual command knows how to undo/redo by itself.

    • Pros: Will use less memory (e.g. for delete, just save the person being deleted).

    • Cons: We must ensure that the implementation of each individual command are correct.

Aspect: Data structure to support the undo/redo commands
  • Alternative 1 (current choice): Use a list to store the history of address book states.

    • Pros: Easy for new Computer Science student undergraduates to understand, who are likely to be the new incoming developers of our project.

    • Cons: Logic is duplicated twice. For example, when a new command is executed, we must remember to update both HistoryManager and VersionedAddressBook.

  • Alternative 2: Use HistoryManager for undo/redo

    • Pros: We do not need to maintain a separate list, and just reuse what is already in the codebase.

    • Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as HistoryManager now needs to do two different things.

3.4. [Proposed] Data Encryption

{Explain here how the data encryption feature will be implemented}

3.5. Logging

We are using java.util.logging package for logging. The LogsCenter class is used to manage the logging levels and logging destinations.

  • The logging level can be controlled using the logLevel setting in the configuration file (See Section 3.6, “Configuration”)

  • The Logger for a class can be obtained using LogsCenter.getLogger(Class) which will log messages according to the specified logging level

  • Currently log messages are output through: Console and to a .log file.

Logging Levels

  • SEVERE : Critical problem detected which may possibly cause the termination of the application

  • WARNING : Can continue, but with caution

  • INFO : Information showing the noteworthy actions by the App

  • FINE : Details that is not usually noteworthy but may be useful in debugging e.g. print the actual list instead of just its size

3.6. Configuration

Certain properties of the application can be controlled (e.g user prefs file location, logging level) through the configuration file (default: config.json).

4. Documentation

Refer to the guide here.

5. Testing

Refer to the guide here.

6. Dev Ops

Refer to the guide here.

Appendix A: Product Scope

Target user profile:

  • has a need to manage classes and related tasks

  • has a need to track earnings

  • prefer desktop apps over other types

  • can type fast

  • prefers typing over mouse input

  • is reasonably comfortable using CLI apps

Value proposition: manage calendar and track earnings faster than a typical mouse/GUI driven app

Appendix B: 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 task

check the details of the task when I want

* * *

user

edit an existing task

update task information when I need

* * *

tutor user

check the time I spent on preparing tutorial materials

ask for salary

* * *

* * *

* * *

* *

forgetful tutor user

be reminded before my tutorials

go for the tutorials on time

*

caring tutor user

check the upcoming events

remind my students

{More to be added}

Appendix C: Use Cases

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

Use case: Delete task

MSS

  1. User requests to list tasks

  2. TutorAid shows a list of tasks

  3. User requests to delete a specific task in the list

  4. TutorAid deletes the person

    Use case ends.

Extensions

  • 2a. The list is empty.

    • 2a1. TutorAid tells user that there is no task.

      Use case ends.

  • 3a. The given index is invalid.

    • 3a1. TutorAid shows an error message.

      Use case resumes at step 2.

{More to be added}

Appendix D: Non Functional Requirements

  1. Should work on any mainstream OS as long as it has Java 11 or above installed.

  2. Should be able to hold up to 1000 tasks 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.

{More to be added}

Appendix E: Glossary

Mainstream OS

Windows, Linux, Unix, OS-X

Private contact detail

A contact detail that is not meant to be shared with others

Appendix F: Product Survey

Product Name

Author: …​

Pros:

  • …​

  • …​

Cons:

  • …​

  • …​

Appendix G: Instructions for Manual Testing

Given below are instructions to test the app manually.

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

G.1. 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.

{ more test cases …​ }

G.2. Deleting a person

  1. Deleting a person while all persons are listed

    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. Timestamp in the status bar is updated.

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

    4. Other incorrect delete commands to try: delete, delete x (where x is larger than the list size) {give more}
      Expected: Similar to previous.

{ more test cases …​ }

G.3. Saving data

  1. Dealing with missing/corrupted data files

    1. {explain how to simulate a missing/corrupted file and the expected behavior}

{ more test cases …​ }