This project is based on the AddressBook-Level3 project created by the SE-EDU initiative.
Refer to the guide Setting up and getting started.
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:
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.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),
interface
with the same name as the Component.{Component Name}Manager
class (which follows the corresponding API interface
mentioned in the previous point.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.
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.Model
data so that the UI can be updated with the modified data.Logic
component, because the UI
relies on the Logic
to execute commands.Model
component, as it displays Person
object residing in the Model
.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 reaches the end of diagram.
How the Logic
component works:
Logic
is called upon to execute a command, it is passed to an AddressBookParser
object which in turn creates a parser that matches the command (e.g., DeleteCommandParser
) and uses it to parse the command.Command
object (more precisely, an object of one of its subclasses e.g., DeleteCommand
) which is executed by the LogicManager
.Model
when it is executed (e.g. to delete a person).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:
AddressBookParser
class creates an XYZCommandParser
(XYZ
is a placeholder for the specific command name e.g., AddCommandParser
) which uses the other classes shown above to parse the user command and create a XYZCommand
object (e.g., AddCommand
) which the AddressBookParser
returns back as a Command
object.XYZCommandParser
classes (e.g., AddCommandParser
, DeleteCommandParser
, ...) inherit from the Parser
interface so that they can be treated similarly where possible e.g, during testing.API : Model.java
The Model
component,
Person
objects (which are contained in a UniquePersonList
object).Person
objects (e.g., results of a search query) as a separate filtered list which is exposed to outsiders as 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.UserPref
object that represents the user’s preferences. This is exposed to the outside as a ReadOnlyUserPref
objects.Model
represents data entities of the domain, they should make sense on their own without depending on other components)Note: An alternative (arguably, a more OOP) model is given below.
API : Storage.java
The Storage
component,
AddressBookStorage
and UserPrefStorage
, which means it can be treated as either one (if only the functionality of only one is needed).Model
component (because the Storage
component's job is to save/retrieve objects that belong to the Model
)Classes used by multiple components are in the seedu.addressbook.commons
package.
This section describes some noteworthy details on how certain features are implemented.
The add
feature allows user to add up to five different details of a person, including the name, role the person,
contact details, the course the person is taking, as well as the respective tutorial classes.
name
field.role
, contact
and course
are optional.course
, users can also choose to include or not to include the tutorial classes of the course.the list
feature allows user to get the information (name, role,
contact details, courses, tutorial classes) of all the people stored.
list
commandThe delete feature allows the user to delete a person that they don't want to view anymore or a person with fields that have to be edited (such that they can add the person with the same name but with edited fields after deleting the original). It identifies the person based on its displayed index in the person list.
DeleteCommandParser#parse(String args)
-- Parses the user input and creates a DeleteCommand
object.DeleteCommand#execute(Model model)
-- Executes the command to delete a person identified by the index in the person list
and returns a CommandResult
object.Given below is an example usage scenario and how the delete feature behaves at each step:
delete
command with the person index. For instance, delete 1
will favourite the person at index 1.AddressBookParser
. DeleteCommandParser
object then is created.DeleteCommandParser
object parses the user input and creates an DeleteCommand
object with the given INDEX
which
represents the index of the Person
to be deleted in the person list.DeleteCommand#execute(Model model)
calls Model::getFilteredPersonList
and gets the specified Person
from the filtered person list using the index.execute
method then calls the deletePerson
method in the ModelManager
with the specified Person
to be deleted.execute
method is returned as a CommandResult
object, which is returned back to the LogicManager
.The following sequence diagram shows how the delete operation works:
Note
DeleteCommandParser
should end at the destroy marker [X].
The favourite feature allows the user to favourite persons that they want to view on a frequent basis. It identifies the person based on its displayed index in the person list.
FavouriteCommandParser#parse(String args)
-- Parses the user input and creates a FavouriteCommand
object.FavouriteCommand#execute(Model model)
-- Executes the command to favourite a person identified by the index in the person list
and returns a CommandResult
object.Given below is an example usage scenario and how the favourite feature behaves at each step:
fav
command with the person index. For instance, fav 1
will favourite the person at index 1.AddressBookParser
. FavouriteCommandParser
object then is created.FavouriteCommandParser
object parses the user input and creates an FavouriteCommand
object with the given INDEX
which
represents the index of the Person
to be favourited in the person list.FavouriteCommand#execute(Model model)
calls Model::getFilteredPersonList
and gets the specified Person
from the filtered person list using the index.execute
method then calls the favouritePerson
method in the ModelManager
with the specified Person
to be favourited.execute
method will call the setPerson
method in the ModelManager
to set the current Person
to
a new Person
with the same fields as the current Person
, except that the isFavourite
field is set to true
.execute
method is returned as a CommandResult
object, which is returned back to the LogicManager
.The following sequence diagram shows how the unfavourite operation works:
Note
FavouriteCommandParser
should end at the destroy marker [X].
The unfavourite feature allows the user to unfavourite favourited persons that they do not want to view on a frequent basis anymore. It identifies the person based on its displayed index in the person list.
UnfavouriteCommandParser#parse(String args)
-- Parses the user input and creates a UnfavouriteCommand
object.UnfavouriteCommand#execute(Model model)
-- Executes the command to unfavourite a person identified by the index in the person list
and returns a CommandResult
object.Given below is an example usage scenario and how the unfavourite feature behaves at each step:
unfav
command with the person index. For instance, unfav 1
will unfavourite the person at index 1.AddressBookParser
. UnfavouriteCommandParser
object then is created.UnfavouriteCommandParser
object parses the user input and creates an UnfavouriteCommand
object with the given INDEX
which
represents the index of the Person
to be unfavourited in the person list.UnfavouriteCommand#execute(Model model)
calls Model::getFilteredPersonList
and gets the specified Person
from the filtered person list using the index.execute
method then calls the unfavouritePerson
method in the ModelManager
with the specified Person
to be unfavourited.execute
method will call the setPerson
method in the ModelManager
to set the current Person
to
a new Person
with the same fields as the current Person
, except that the isFavourite
field is set to false
.execute
method is returned as a CommandResult
object, which is returned back to the LogicManager
.The following sequence diagram shows how the unfavourite operation works:
Note
UnfavouriteCommandParser
should end at the destroy marker [X].
High Level Description:
The favourite list feature is executed using the favlist
command.
FavList Command
A FavListCommand Java class that extends the parent Command class will be created. This base class
will represent the favlist
command
Command Word
A constant COMMAND_WORD = "favlist" is instantiated.
Usage Message
A usage message constant MESSAGE_USAGE will be created to explain to the users how to interact and
use the favlist
command
Integration with Model
To ensure that the FavListCommand class interacts with the application's model
to perform actions related to the favorite list. This will be done through the
model.updateFilteredPersonList(predicate)
method.
In essence, the sequence of events is illustrated by the following activity diagram:
favlist
command.
Description:
The search feature contains 4 different sub commands namely : search
, searchrole
,
searchcourse
, searchtutorial
.
search
allows the user to search for a person through their namesearchrole
allows the user to search for a list of people with the same rolesearchcourse
allows the user to search for a list of people taking a particular coursesearchtutorial
allows the user to search for a list of people taking a particular tutorialImplementation:
search
A `search` class has a `NameContainsKeywordPredicate` field that describes the search criteria and filters the list of persons.`NameContainsKeywordPredicate` implements the Predicate interface for Person object. It is used to filter a collection of Person objects based on whether their names contain a certain keyword.
In essence, the sequence of events is illustrated by the following activity diagram:
searchrole
A `searchrole` class has a `RoleContainsKeywordPredicate` field that describes the search criteria and filters the list of persons. `RoleContainsKeywordPredicate` implements the Predicate interface for Person object. It is used to filter a collection of Person objects based on whether their role contain a certain keyword.
In essence, the sequence of events is illustrated by the following activity diagram:
searchcourse
A `searchcourse` class has a `CourseContainsKeywordPredicate` field that describes the search criteria and filters the list of persons. `CourseContainsKeywordPredicate` implements the Predicate interface for Person object. It is used to filter a collection of Person objects based on whether their courses contain a certain keyword.
In essence, the sequence of events is illustrated by the following activity diagram:
searchtutorial
A `searchtutorial` class has a `TutorialContainsKeywordPredicate` field that describes the search criteria and filters the list of persons. `TutorialContainsKeywordPredicate` implements the Predicate interface for Person object. It is used to filter a collection of Person objects based on whether their tutorials contain a certain keyword.
In essence, the sequence of events is illustrated by the following activity diagram:
Having distinct search commands for different purposes instead of a single search command that searches all four makes it clear to the user what each command is used for. Hence, this will make the interface more user-friendly as it reduces the likelihood of the users getting confused about the commands.
2. ScalabilityIf the search feature were to be expanded or modified in the future, it would be easier to add or change specific commands and their functions without affecting the whole search system.
Additionally, if the search feature was to modified to allow multiple searches in a single command, If a single search command was used, users may need to use complex syntax to specify what they are searching for. Hence, having 4 different search commands will reduce ambiguity and hence make it more scalable.
3. Improved Error HandlingWith a specific search command for each search, it is easier to give specific and targeted error messages. For a single search command that handles multiple types of searches, providing relevant feedback can be more challenging. Hence, the error messages for a single search command might not be specific, making the application less user-friendly.
The autocomplete feature relies on the Map
from Command Words to CheckedFunction
in the AddressBookParser.java
named wordToCommandMap
. On instantiation, this Map
is populated with each Command Word as keys, and their respective values as lambda CheckedFunction
s taking in the String
userInput as arguments and returning a parsed version of their respective function. For example, a short excerpt is shown below;
/**
* Initialize the word to command map. Remember each command word maps to a lambda function
* that will return the parsed Command object. This command object will then be executed.
*/
public AddressBookParser() {
// Command taking in arguments
wordToCommandMap.put(AddCommand.COMMAND_WORD, (arguments) -> new AddCommandParser().parse(arguments));
// Command taking in no arguments; no need to parse via parser
wordToCommandMap.put(ClearCommand.COMMAND_WORD, (arguments) -> new ClearCommand());
// ...
}
Once all the command words are stored in the map, the autocomplete feature will, on key pressed in the command box, check for any command that starts with the String
input supplied by the user, and iterate through them one by one. In essence, the sequence of events is illustrated by the following activity diagram:
HashMap
implementation was chosen for AddressBookParser
's command word storage data structure as lookup for command words can be done in approximately O(1)
time.
The proposed 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 --name 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
.
Note: 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.
Note: If the currentStatePointer
is at index 0, pointing to the initial AddressBook state, then there are no previous AddressBook 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:
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.
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.
Note: If the currentStatePointer
is at index addressBookStateList.size() - 1
, pointing to the latest address book state, then there are no undone AddressBook 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. 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:
Aspect: How undo & redo executes:
Alternative 1 (current choice): Saves the entire address book.
Alternative 2: Individual command knows how to undo/redo by itself.
delete
, just save the person being deleted).{more aspects and alternatives to be added}
The edit feature allows users to edit specific fields in a person they want to edit. It identifies the person based on its displayed index in the person list.
EditCommandParser#parse(String args)
-- Parses the user input and creates a EditCommand
object.EditCommand#execute(Model model)
-- Executes the command to edit a person identified by the index in the person list
and returns a CommandResult
object.Given below is an example usage scenario and how the edit feature behaves at each step.
edit
command with the person index and the specifiers of the attribute to be edited. For instance,
edit 1 --name new name
will edit the name of the person at index 1 to new name
.AddressBookParser
. EditCommandParser
object is created, which creates an EditPersonDescriptor
object.
This EditPersonDescriptor
object contains the new fields which is to be in the new edited Person
.EditCommand
object is then constructed with this EditPersonDescriptor
object and the index of the person to be edited.EditCommand
object gets the Person
to be edited from the filtered person list using the index.EditCommand
object then creates an edited Person
from the specified Person
and theEditPersonDescriptor
object.EditCommand
object then calls the setPerson
method in ModelManager
with the edited Person
. This sets the Person
specified by the index
in the model to be that edited Person
.EditCommand
object updates the person list to then display the edited Person
in the UI.The following sequence diagram illustrates the above steps for editing a Person
.
Note
EditCommandParser
should end at the destroy marker [X].
Target user profile:
NUS students:
Value proposition:
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 |
* * * | NUS student | add my classmates, professors and teaching assistants profiles in | easily keep track of my peers and mentors in NUS |
* * * | NUS student | my classmates, professors or teaching assistants profiles | remove entries that I no longer need |
* * * | NUS student | search a profile by name | locate details of a person without having to go through the entire list |
* * | NUS student | view the list of profiles added | |
* | NUS student | favourite profiles I would view often | easily view their profiles when using the app |
* * * | NUS student | close the app when I am done using it | |
* * | NUS student | save my favourite professors, teaching assistants, and classmates in a personal contact list within NUSearch | reach out to them easily in the future |
* * | Professor | include my don’t disturb timings I can reach out to them easily in the future | so that I can have better work life balance |
* * | NUS student | delete my classmates, professors or teaching assistants profiles | I can remove entries I no longer need |
* | NUS student | find the direction to my tutorial / lecture classrooms | I will not get lost on campus. |
(For all use cases below, the System is NUSearch
and the Actor is the User
, unless specified otherwise)
System: NUSearch Use case: UC1 - Add a new profile Actor: User
MSS
Extensions
System: NUSearch Use case: UC2 - Asking for help Actor: User MSS
System: NUSearch Use case: UC3 - Asking for List Actor: User MSS
Extensions
System: NUSearch Use case: UC4 - Exit Actor: User MSS
System: NUSearch Use case: UC5 - Add favorite Actor: User MSS
Extensions
System: NUSearch Use case: UC6 - Search for a profile Actor: User MSS
Extensions
{More to be added}
11
or above installed.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.
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 being shown
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)
Expected: Similar to previous.
{ more test cases … }
Dealing with missing/corrupted data files
{ more test cases … }