By: AY1920S2-CS2103T-W13-1
Since: Mar 2020
Licence: MIT
Refer to the guide here.
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.
|
-
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.
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.
The Sequence Diagram below shows how the components interact with each other for the scenario where the user issues the command delete 1
.
The sections below give more details of each 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.
API :
Logic.java
-
Logic
uses theAddressBookParser
class to parse the user command. -
This results in a
Command
object which is executed by theLogicManager
. -
The command execution can affect the
Model
(e.g. adding a person). -
The result of the command execution is encapsulated as a
CommandResult
object which is passed back to theUi
. -
In addition, the
CommandResult
object can also instruct theUi
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.
ℹ️
|
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.
|
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.
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.
This section describes some noteworthy details on how certain features are implemented.
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.
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.
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
.
ℹ️
|
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.
ℹ️
|
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:
ℹ️
|
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.
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.
The following activity diagram summarizes what happens when a user executes a new command:
-
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.
-
-
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
andVersionedAddressBook
.
-
-
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.
-
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 usingLogsCenter.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
Refer to the guide here.
Refer to the guide here.
Refer to the guide here.
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
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. |
(For all use cases below, the System is the EYLAH
and the Actor is the user
, unless specified otherwise)
MSS
-
User chooses dieting mode (i.e. Weight Loss, Weight Gain, Maintain)
-
EYLAH updates users' dieting mode
-
User updates height
-
EYLAH updates height of user
-
User updates weight
-
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.
-
MSS
-
User adds food item
-
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.
-
MSS
-
User lists out existing items
-
EYLAH shows the list based on flags entered
-
User deletes item by index
-
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.
-
MSS
-
User lists out existing items
-
EYLAH shows the list based on flags entered
-
User edits item by index
-
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.
-
MSS
-
User lists out existing items
-
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.
-
MSS
-
User calls the command
-
EYLAH shows the list food, their calories, as well as the total calories consumed for the day
-
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
-
MSS
-
User calls
bmi
command, with optional height and weight entered -
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
-
MSS
-
User keys in the Person(s) name followed by some additional details, such as Telegram username and room number.
-
EYLAH adds Person(s) to the PersonList.
-
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.
-
MSS
-
User keys in Food name, its price and Person(s) involved in the splitting of that food.
-
EYLAH adds the Food object.
-
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.
-
MSS
-
User keys in request to calculate the cost.
-
EYLAH calculates each Person(s)'s cost.
-
EYLAH display cost.
Use case ends.
MSS
-
User requests to list the food items.
-
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.
-
MSS
-
User requests to list the persons.
-
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.
-
MSS
-
User requests to remove food from the list.
-
EYLAH removes the food from the list.
-
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.
-
MSS
-
User requests to remove a person from the list.
-
EYLAH removes the person from the list.
-
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.
-
-
Should work on any mainstream OS as long as it has Java
11
or above installed. -
Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage.
-
Should be able to hold up to 1000 food items without a noticeable sluggishness in performance for typical usage.
-
Should have a pre-loaded list of commonly consumed food items in database.
-
Should be able to work without internet access.
-
A user should be able to use EYLAH easily and intuitively.
-
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}
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. |
-
Initial launch
-
Download the jar file and copy into an empty folder
-
Double-click the jar file
Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.
-
-
Saving window preferences
-
Resize the window to an optimum size. Move the window to a different location. Close the window.
-
Re-launch the app by double-clicking the jar file.
Expected: The most recent window size and location is retained.
-
{ more test cases … }
-
Deleting a person while all persons are listed
-
Prerequisites: List all persons using the
list
command. Multiple persons in the list. -
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. -
Test case:
delete 0
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. -
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 … }