Skip to content

Latest commit

 

History

History
779 lines (545 loc) · 25.5 KB

DeveloperGuide.adoc

File metadata and controls

779 lines (545 loc) · 25.5 KB

EYLAH - 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. [Proposed] Undo/Redo feature

3.1.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.1.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.2. [Proposed] Data Encryption

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

3.3. 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.4, “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.4. 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:

  • Temasek Hall residents

  • Diet-conscious residents

  • Residents who frequently pays on behalf of a group

  • Residents who prefer desktop applications

  • Residents who can type fast

  • Residents who prefer typing over using the mouse

  • Residents who are reasonably comfortable using CLI applications

Value proposition: manage diet and expenses 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…​

* * *

Temasek Hall resident

want to keep track of my expenses accurately

calculate the exact amount I should collect from my friends after each time we split a meal

* * *

healthy hall resident who is trying to lose weight

check how many calories I took today

keep track of my calories intake and weight

* * *

Temasek hall resident who frequents supper food spots

split the bill easily with fellow mates

ensure that the amount is correctly accounted for

* * *

Temasek Hall resident who wants to stay healthy

keep track of my calories

more accurately watch my weight

*

Temasek Hall leader

keep track of my committee events

know if things are going according to schedule

*

Temasek Hall exchange student

to have a translation for Singaporean lingo

better understand the language my friends speak in hall

*

Temasek Hall sports captain

to keep track of the various attendances for my training

know who usually attends training and who does not

*

Temasek Hall leader

to keep track of my committee events

ensure things run smoothly

*

Temasek Hall resident who actively participates in hall events

check the upcoming events

keep myself up-to-date.

Appendix C: Use Cases

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

Diet Tracker Use Cases

Use case: UC01 Update User Profile

MSS

  1. User chooses dieting mode (i.e. Weight Loss, Weight Gain, Maintain)

  2. EYLAH updates users' dieting mode

  3. User updates height

  4. EYLAH updates height of user

  5. User updates weight

  6. EYLAH updates weight of user

    Use case ends.

Extensions

  • 1a. The flag field for dieting mode is empty or flag is invalid.

    • 1a1. EYLAH requests user to re-enter command with flag

    • 1a2. User enters command with flag
      Steps 1a1-1a2 are repeated until the correct entered is correct.
      Use case resumes from step 3.

  • 3a. Height field is empty or in invalid format.

    • 3a1. EYLAH requests user to re-enter height in correct format

    • 3a2. User enters command with height in correct format
      Steps 3a1-3a2 are repeated until the correct entered is correct.
      Use case resumes from step 5.

  • 5a. Weight field is empty or in invalid format.

    • 5a1. EYLAH requests user to re-enter weight in correct format

    • 5a2. User enters command with weight in correct format
      Steps 5a1-5a2 are repeated until the correct entered is correct.
      Use case ends.

Use case: UC02 Add Food Item

MSS

  1. User adds food item

  2. EYLAH adds food item to user’s log

    Use case ends.

Extensions

  • 1a. The food item is added in an invalid format or certain fields are missing.

    • 1a1. EYLAH requests user to re-enter food item in valid format.

    • 1a2. User enters command in the correct format as requested by EYLAH
      Steps 1a1-1a2 are repeated until the correct entered is correct.
      Use case ends.

Use case: UC03 Delete Food Item

MSS

  1. User lists out existing items

  2. EYLAH shows the list based on flags entered

  3. User deletes item by index

  4. EYLAH deletes item tagged to specified index

    Use case ends.

Extensions

  • 1a. List command contains invalid flag.

    • 1a1. EYLAH prints out default list which contains food logged for the day

  • 3a. Invalid or empty index keyed into command.

    • 3a1. EYLAH requests user to re-enter index in correct format

    • 3a2. User enters delete item in correct format
      Steps 3a1-3a2 are repeated until the correct entered is correct.
      Use case ends.

Use case: UC04 Edit Food Item

MSS

  1. User lists out existing items

  2. EYLAH shows the list based on flags entered

  3. User edits item by index

  4. EYLAH edits the data of the item stored at the index.

    Use case ends.

Extensions

  • 1a. List command contains invalid flag.

    • 1a1. EYLAH prints out default list which contains food logged for the day

  • 3a. Invalid or empty index keyed into command.

    • 3a1. EYLAH requests user to re-enter index in correct format

    • 3a2. User enters delete item in correct format
      Steps 2a1-2a2 are repeated until the correct entered is correct.
      Use case ends.

  • 3b. No additional tags and data keyed in as flags to replace existing data.

    • 3b1. EYLAH requests user to re-enter command with at least one flag

    • 3b2. User enters command with flag and data
      Steps 3b1-3b2 are repeated until the correct entered is correct.
      Use case ends.

Use case: UC05 List Food Items

MSS

  1. User lists out existing items

  2. EYLAH shows the list based on flags entered

    Use case ends.

Extensions

  • 1a. List command contains invalid flag.

    • 1a1. EYLAH prints out default list which contains food logged for the day

      Use case ends.

Use case: UC06 Calories count

MSS

  1. User calls the command

  2. EYLAH shows the list food, their calories, as well as the total calories consumed for the day

  3. User can track their remaining calories via the interface, based on their input height and weight

    Use case ends.

Extensions

  • 1a. Invalid argument keyed into command.

    • 1a1. EYLAH would raise a "errorneous argument" message

    • 1a2. EYLAH would run the command and calculate the outputs ignoring additional arguments

Use case: UC07 Calculate BMI

MSS

  1. User calls bmi command, with optional height and weight entered

  2. EYLAH calculates and shows user’s BMI based on the height and weight

    Use case ends.

Extensions

  • 1a. BMI command contains invalid flag.

    • 1a1. EYLAH suggests to user the correct format to use

    • 1a2. User will key in the correct format

Expense Splitter Use Cases

Use case: UC01 - Add person

MSS

  1. User keys in the Person(s) name followed by some additional details, such as Telegram username and room number.

  2. EYLAH adds Person(s) to the PersonList.

  3. EYLAH displays the added person.

    Use case ends.

Extensions

  • 1a. EYLAH detects empty string in place of name.

    • 1a1. EYLAH shows an error message informing user that a Person’s name cannot be empty.

      Use case ends.

  • 1b. Eylah detects invalid syntax in person’s details.

    • 1b1. EYLAH shows an error message informing the user about the incorrect name format.

      Use case ends.

Use case: UC02 - Add food

MSS

  1. User keys in Food name, its price and Person(s) involved in the splitting of that food.

  2. EYLAH adds the Food object.

  3. EYLAH displays the Food and the Person(s) involved with splitting of that food.

    Use case ends.

Extensions

  • 1a. EYLAH detects empty Food name, Food price or Person(s)

    • 1a1. EYLAH shows an error message and displays an example of a correct addfood function.

      Use case ends.

  • 1b. Eylah detects invalid syntax.

    • 1b1. EYLAH shows an error message and displays an example of a correct addfood function.

      Use case ends.

Use case: UC03 - Calculate cost

MSS

  1. User keys in request to calculate the cost.

  2. EYLAH calculates each Person(s)'s cost.

  3. EYLAH display cost.

    Use case ends.

Use case: UC04 - Listing food items

MSS

  1. User requests to list the food items.

  2. EYLAH displays the list of food items.

    Use case ends.

Extensions

  • 1a. EYLAH detects an empty list.

    • 1a1. EYLAH displays an error message.

      Use case ends.

  • 1b. EYLAH detects invalid syntax.

    • 1b1. EYLAH displays an error message.

      Use case ends.

Use case: UC05 - Listing the persons

MSS

  1. User requests to list the persons.

  2. EYLAH displays the list of persons.

    Use case ends.

Extensions

  • 1a. EYLAH detects an empty list.

    • 1a1. EYLAH displays an error message.

      Use case ends.

  • 1b. EYLAH detects invalid syntax.

    • 1b1. EYLAH displays an error message.

      Use case ends.

Use case: UC06 - Removing food

MSS

  1. User requests to remove food from the list.

  2. EYLAH removes the food from the list.

  3. EYLAH displays the list of food.

    Use case ends.

Extensions

  • 1a. EYLAH detects an empty list.

    • 1a1. EYLAH displays an error message.

  • 1b. EYLAH detects invalid syntax.

    • 1b1. EYLAH displays an error message.

  • 1c. EYLAH detects that the food does not exist in the list.

    • 1c1. EYLAH displays an error message.

      Use case ends.

Use case: UC07 - Removing person

MSS

  1. User requests to remove a person from the list.

  2. EYLAH removes the person from the list.

  3. EYLAH displays the list of persons.

    Use case ends.

Extensions

  • 1a. EYLAH detects an empty list.

    • 1a1. EYLAH displays an error message.

  • 1b. EYLAH detects invalid syntax.

    • 1b1. EYLAH displays an error message.

  • 1c. EYLAH detects that the person does not exist in the list.

    • 1c1. EYLAH displays an error message.

      Use case ends.

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 persons without a noticeable sluggishness in performance for typical usage.

  3. Should be able to hold up to 1000 food items without a noticeable sluggishness in performance for typical usage.

  4. Should have a pre-loaded list of commonly consumed food items in database.

  5. Should be able to work without internet access.

  6. A user should be able to use EYLAH easily and intuitively.

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

Temasek Hall

A Hall of Residences in National University of Singapore

CLI

Command Line Interface

Syntax

The structure of statements in the command

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 …​ }