Skip to content

Latest commit

 

History

History
1692 lines (1163 loc) · 87.5 KB

DeveloperGuide.adoc

File metadata and controls

1692 lines (1163 loc) · 87.5 KB

Medeina - Developer Guide

By: Team SE-EDU      Since: Jun 2016      Licence: MIT

1. Introduction

Welcome to Medeina! Medeina is a application designed to help veterinarians and their assistants to manage contacts and appointments. Medeina is a command-line based application, all actions can be done using only keyboard. This developer guide aims to help new developers to get started with Medeina, and also serves as a reference for even experienced Medeina contributors.

2. Setting up

2.1. Prerequisites

To successfully install and run Medeina, you’ll need the following:

  1. JDK 1.8.0_60 or later

    ℹ️
    Having any Java 8 version is not enough.
    This app will not work with earlier versions of Java 8.
  2. IntelliJ IDE

    ℹ️
    IntelliJ by default has Gradle and JavaFx plugins installed.
    Do not disable them. If you have disabled them, go to File > Settings > Plugins to re-enable them.

2.2. Setting up the project in your computer

To set up Medeina in your computer, follow these steps:

  1. Fork this repo, and clone the fork to your computer

  2. Open IntelliJ (if you are not in the welcome screen, click File > Close Project to close the existing project dialog first)

  3. Set up the correct JDK version for Gradle

    1. Click Configure > Project Defaults > Project Structure

    2. Click New…​ and find the directory of the JDK

  4. Click Import Project

  5. Locate the build.gradle file and select it. Click OK

  6. Click Open as Project

  7. Click OK to accept the default settings

  8. Open a console and run the command gradlew processResources (Mac/Linux: ./gradlew processResources). It should finish with the BUILD SUCCESSFUL message.
    This will generate all resources required by the application and tests.

2.3. Verifying the setup

To check if the setup is successful:

  1. Run the seedu.address.MainApp and try a few commands

  2. Run the tests to ensure they all pass.

2.4. Configurations to do before writing code

Before you start contributing to Medeina, the following configurations are required:

2.4.1. Configuring the coding style

This project follows oss-generic coding standards. IntelliJ’s default style is mostly compliant with ours but it uses a different import order from ours. To rectify,

  1. Go to File > Settings…​ (Windows/Linux), or IntelliJ IDEA > Preferences…​ (macOS)

  2. Select Editor > Code Style > Java

  3. Click on the Imports tab to set the order

    • For Class count to use import with '*' and Names count to use static import with '*': Set to 999 to prevent IntelliJ from contracting the import statements

    • For Import Layout: The order is import static all other imports, import java.*, import javax.*, import org.*, import com.*, import all other imports. Add a <blank line> between each import

Optionally, you can follow the UsingCheckstyle.adoc document to configure Intellij to check style-compliance as you write code.

2.4.2. Updating documentation to match your fork

After forking the repo, links in the documentation will still point to the se-edu/addressbook-level4 repo. If you plan to develop this as a separate product (i.e. instead of contributing to the se-edu/addressbook-level4) , you should replace the URL in the variable repoURL in DeveloperGuide.adoc and UserGuide.adoc with the URL of your fork.

2.4.3. Setting up CI

Set up Travis to perform Continuous Integration (CI) for your fork. See UsingTravis.adoc to learn how to set it up.

After setting up Travis, you can optionally set up coverage reporting for your team fork (see UsingCoveralls.adoc).

ℹ️
Coverage reporting could be useful for a team repository that hosts the final version but it is not that useful for your personal fork.

Optionally, you can set up AppVeyor as a second CI (see UsingAppVeyor.adoc).

ℹ️
Having both Travis and AppVeyor ensures your App works on both Unix-based platforms and Windows-based platforms (Travis is Unix-based and AppVeyor is Windows-based)

2.4.4. Getting started with coding

When you are ready to start coding,

  1. Get some sense of the overall design by reading Section 3.1, “Architecture”.

  2. Take a look at Appendix A, Suggested Programming Tasks to Get Started.

3. Design

3.1. Architecture

Architecture
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 .pptx files used to create diagrams in this document can be found in the diagrams folder. To update a diagram, modify the diagram in the pptx file, select the objects of the diagram, and choose Save as picture.

Main has only one class called 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. Two of those classes play important roles at the architecture level.

  • EventsCenter : This class (written using Google’s Event Bus library) is used by components to communicate with other components using events (i.e. a form of Event Driven design)

  • 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

The above diagram shows the relations between each subcomponents within the Logic component.

Events-Driven nature of the design

The Sequence Diagram below shows how the components interact for the scenario where the user issues the command delete -o 1.

SDforDeletePerson
Figure 3. Component interactions for delete -o 1 command (part 1)
ℹ️
Note how the Model simply raises a AddressBookChangedEvent when the Address Book data are changed, instead of asking the Storage to save the updates to the hard disk.

The diagram below shows how the EventsCenter reacts to that event, which eventually results in the updates being saved to the hard disk and the status bar of the UI being updated to reflect the 'Last Updated' time.

SDforDeletePersonEventHandling
Figure 4. Component interactions for delete 1 command (part 2)
ℹ️
Note how the event is propagated through the EventsCenter to the Storage and UI without Model having to be coupled to either of them. This is an example of how this Event Driven approach helps us reduce direct coupling between components.

The sections below give more details of each component.

3.2. UI component

The following diagram displays the structure of the UI component.

UiClassDiagram
Figure 5. 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.

  • Binds itself to some data in the Model so that the UI can auto-update when data in the Model change.

  • Responds to events raised from various parts of the App and updates the UI accordingly.

3.3. Logic component

The following diagram displays the structure of the Logic component.

LogicClassDiagram
Figure 6. Structure of the Logic Component

The following diagram displays the structures of the commands in Logic component.

LogicCommandClassDiagram
Figure 7. Structure of Commands in the Logic Component. This diagram shows finer details concerning XYZCommand and Command in Figure 6, “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) and/or raise events.

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

3.4. Model component

ModelClassDiagramUpdated
Figure 8. Structure of the Model Component

API : Model.java

The Model,

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

  • stores Medeina’s data.

  • exposes unmodifiable ObservableList<Person>, ObservableList<PetPatient> and ObservableList<Appointment> 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.

3.5. Storage component

StorageClassDiagram
Figure 9. Structure of the Storage Component

API : Storage.java

The Storage component,

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

  • can save Medeina’s Address Book data in xml format and read it back.

3.6. Common classes

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

4. Implementation

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

4.1. Undo/Redo feature

4.1.1. Current Implementation

The undo/redo mechanism is facilitated by an UndoRedoStack, which resides inside LogicManager. It supports undoing and redoing of commands that modifies the state of Medeina (e.g. add, edit). Such commands will inherit from UndoableCommand.

UndoRedoStack only deals with UndoableCommands. Commands that cannot be undone will inherit from Command instead. The following diagram shows the inheritance diagram for commands:

LogicCommandClassDiagram

As you can see from the diagram, UndoableCommand adds an extra layer between the abstract Command class and concrete commands that can be undone, such as the DeleteCommand. Note that extra tasks need to be done when executing a command in an undoable way, such as saving the state of Medeina before execution. UndoableCommand contains the high-level algorithm for those extra tasks while the child classes implements the details of how to execute the specific command. Note that this technique of putting the high-level algorithm in the parent class and lower-level steps of the algorithm in child classes is also known as the template pattern.

Commands that are not undoable are implemented this way:

public class ListCommand extends Command {
    @Override
    public CommandResult execute() {
        // ... list logic ...
    }
}

With the extra layer, the commands that are undoable are implemented this way:

public abstract class UndoableCommand extends Command {
    @Override
    public CommandResult execute() {
        // ... undo logic ...

        executeUndoableCommand();
    }
}

public class DeleteCommand extends UndoableCommand {
    @Override
    public CommandResult executeUndoableCommand() {
        // ... delete logic ...
    }
}

Suppose that the user has just launched the application. The UndoRedoStack will be empty at the beginning.

The user executes a new UndoableCommand, delete 5, to delete the 5th person in Medeina’s address book. The current state of Medeina is saved before the delete 5 command executes. The delete 5 command will then be pushed onto the undoStack (the current state is saved together with the command).

UndoRedoStartingStackDiagram

As the user continues to use the program, more commands are added into the undoStack. For example, the user may execute add n/David …​ to add a new person.

UndoRedoNewCommand1StackDiagram
ℹ️
If a command fails its execution, it will not be pushed to the UndoRedoStack at all.

The user now decides that adding the person was a mistake, and decides to undo that action using undo.

We will pop the most recent command out of the undoStack and push it back to the redoStack. We will restore Medeina to the state before the add command executed.

UndoRedoExecuteUndoStackDiagram
ℹ️
If the undoStack is empty, then there are no other commands left to be undone, and an Exception will be thrown when popping the undoStack.

The following sequence diagram shows how the undo operation works:

UndoRedoSequenceDiagram

The redo does the exact opposite (pops from redoStack, push to undoStack, and restores Medeina to the state after the command is executed).

ℹ️
If the redoStack is empty, then there are no other commands left to be redone, and an Exception will be thrown when popping the redoStack.

The user now decides to execute a new command, clear. As before, clear will be pushed into the undoStack. This time the redoStack is no longer empty. It will be purged as it no longer make sense to redo the add n/David command (this is the behavior that most modern desktop applications follow).

UndoRedoNewCommand2StackDiagram

Commands that are not undoable are not added into the undoStack. For example, list, which inherits from Command rather than UndoableCommand, will not be added after execution:

UndoRedoNewCommand3StackDiagram

The following activity diagram summarize what happens inside the UndoRedoStack when a user executes a new command:

UndoRedoActivityDiagram

4.1.2. Design Considerations

Aspect: Implementation of UndoableCommand
  • Alternative 1 (current choice): Add a new abstract method executeUndoableCommand()

    • Pros: We will not lose any undone/redone functionality as it is now part of the default behaviour. Classes that deal with Command do not have to know that executeUndoableCommand() exist.

    • Cons: Hard for new developers to understand the template pattern.

  • Alternative 2: Just override execute()

    • Pros: Does not involve the template pattern, easier for new developers to understand.

    • Cons: Classes that inherit from UndoableCommand must remember to call super.execute(), or lose the ability to undo/redo.

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

    • 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: Type of commands that can be undone/redone
  • Alternative 1 (current choice): Only include commands that modifies Medeina (add, clear, edit).

    • Pros: We only revert changes that are hard to change back (the view can easily be re-modified as no data are * lost).

    • Cons: User might think that undo also applies when the list is modified (undoing filtering for example), * only to realize that it does not do that, after executing undo.

  • Alternative 2: Include all commands.

    • Pros: Might be more intuitive for the user.

    • Cons: User have no way of skipping such commands if he or she just want to reset the state of Medeina * and not the view. Additional Info: See our discussion here.

Aspect: Data structure to support the undo/redo commands
  • Alternative 1 (current choice): Use separate stack for undo and redo

    • Pros: Easy to understand 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 UndoRedoStack.

  • Alternative 2: Use HistoryManager for undo/redo

    • Pros: We do not need to maintain a separate stack, 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.

4.2. Autocomplete

The autocomplete feature serves to enhance user experience in using the Command Line Interface (CLI). It currently supports command words, options, prefixes, and parameters such as tags, contact’s NRIC, pet patient’s name, breed, species, colour and blood type.

4.2.1. Current Implementation

The implementation logic of the autocomplete feature resides in the UI component. The autocomplete feature is driven by a ChangeListener attached to commandTextField.textProperty() in CommandBox.java. Once the ChangeListener registers any changes in the content of commandTextField, triggerAutocomplete() will be executed.

Suppose that the user is launching Medeina. Before the Graphical User Interface (GUI) is ready, a CommandBox object will be initialized for the user to enter commands. The following diagram illustrates a sequence of method calls, starting with the initialization of CommandBox, followed by the initialization of an instance of Autocomplete, and then calling 3 set attribute methods in the Logic component. Subsequently, suppose the user has typed add -p n/Happy s/Cat b/Persian c/Calico bt/A -o nr/. The diagram shows a sequence of method calls, starting with triggerAutocomplete(), to get autocomplete suggestions for NRIC to be shown in a context menu.

autocompleteSequenceDiagram
Figure 10. Sequence diagram for autocomplete feature


Autocomplete.java encompasses the logic for parsing user input in the CLI and determining what autocomplete suggestions are to be passed back to CommandBox.java. Data required for autocomplete, such as a list of command words, prefixes, options and parameters in Medeina, are retrieved from the Logic component. All data required by Autocomplete are consolidated in a similar way in the Logic component.

The following code shows how contact’s NRIC and tags are consolidated:

public void setAttributesForPersonObjects() {
    nricInModel = new HashSet<>();
    personTagsInModel = new HashSet<>();

    for (Person p : model.getAddressBook().getPersonList()) {
        nricInModel.add(p.getNric().toString());
        personTagsInModel.addAll(p.getTags());
    }
}

public Set<String> getAllNric() {
    return nricInModel;
}

public Set<String> getAllPersonTags() {
    Set<String> personTags = personTagsInModel.stream()
            .map(pt -> pt.tagName)
            .collect(Collectors.toSet());
    return personTags;
}

You may have noticed that in sequence diagram above (Figure 11), Autocomplete is a singleton class that is initialized only once, and there is only 1 instance of CommandBox in the application. You may be wondering "can the 3 set attribute methods in the Logic component be called only once?". If you are currently unsure, imagine that the user is constantly adding new contacts to Medeina. However, Autocomplete uses only data from when Medeina was launched.

The answer to the question is definitely no. The set attributes methods have to be called whenever there is a change in Medeina’s data, otherwise the autocomplete suggestions will not be up to date.

The following code snippet ensures that the data used by Autocomplete is kept updated.

public void handleAddressBookChangedEvent(AddressBookChangedEvent a) {
    init(this.logic); // calls the 3 set attributes methods
    logger.info(LogsCenter.getEventHandlingLogMessage(a, "Local data has changed, update autocomplete data"));
}

4.2.2. Design considerations

Aspect: Updating autocomplete data
  • Alternative 1 (current choice): All Data is updated only when AddressBookChangedEvent is raised.

    • Pros: Efficient and with minimal redundant updates.

    • Cons: Implementation is less straight-forward.

  • Alternative 2 : Updates the specific required data e.g. NRIC, whenever autocomplete is triggered.

    • Pros: Easy to implement.

    • Cons: Redundant updates. Required data will remain the same, except only when add, delete, or edit commands are executed.

  • Alternative 3: All Data is updated whenever autocomplete is triggered.

    • Pros: Easy to implement.

    • Cons: Many redundant data updates. Running for-loops in the Logic component for every character the user types, is resource-intensive.

Aspect: Event-driven or user-driven
  • Alternative 1 (current choice): Implement change listener to automatically track user input and provide autocomplete suggestions.

    • Pros: Great improvement in user experience, as Medeina has long and complex command syntax.

    • Cons: Logic for handling caret position and command syntax parsing is complicated and can be prone to bugs.

  • Alternative 2: User has to press a specific key e.g. tab to invoke autocompletion.

    • Pros: Less logic to account for, and is thus easier to implement.

    • Cons: User experience is compromised.

4.3. Add Command

4.3.1. Current Implementation

4.3.2. Design considerations

Aspect: Consolidating similar commands
  • Combining variations of the same type of command into a single command with parsing options

    • add Person : add -o n/NAME p/PHONE NUMBER e/EMAIL a/ADDRESS nr/NRIC [t/TAGS]…​

    • add Pet Patient : add -p n/NAME s/SPECIES b/BREED c/COLOUR bt/BLOOD TYPE [t/TAGS]…​ -o [WHO IS THE OWNER]

    • add Appointment : add -a d/DATE r/REMARK [t/TAGS]…​ -o [OWNER] -p [PET PATIENT INVOLVED]

    • add -o [OWNER INFO] -p [PET INFO] -a [APPOINTMENT INFO]

Keeping to one main command is simpler and more user-friendly as compared to having variations of the same type of command. To reduce the amount of typing required, command syntax should be kept as compact as possible. Instead of having separate add commands for each of the 3 classes, combine them into a one-liner command to reduce typing redundant information from dependencies.

4.4. Adding a Pet Patient

4.4.1. Current Implementation

Currently, adding of pet patients is achieved by AddPetPatientCommand. It allows the user to add the details of pet patients, and subsequently stores the details within the storage file.

The implementation of AddPetPatientCommand is rather similar to that of AddCommand.

ℹ️
AddPetPatientCommand, as well as AddCommand, extends UndoableCommand.
public class AddPetPatientCommand extends UndoableCommand {
	// logic for AddPetPatientCommand
}

This brings us to the next section on the design considerations of AddPetPatientCommand.

4.4.2. Design Considerations

Aspect: Implementation of AddPetPatientCommand
  • Alternative 1 (current choice): The command extends UndoableCommand

    • Pros: We can make use of the undo / redo function that was previously implemented. This also allows our users to correct any mistakes that they might have made while keying in the information of the pet patients.

    • Cons: Developers who join our team in the future may have trouble understanding the code base (since we have both UndoableCommand and Command).

  • Alternative 2: The command extends Command instead.

    • Pros: We simplify the code base by removing the use of UndoableCommand.

    • Cons: Users are unable to undo their mistakes. Instead, they will have to go through the hassle of editing / deleting pet patients to resolve the error on their part.

4.4.3. Current Limitations

As of now, the linking of pet patients to their respective owners (and also appointments) has not been implemented.

The implementation of PetPatient tags (i.e. having a separate list of tags from Person) is currently ongoing; as such, there is no support for tagging of pet patients yet.

4.4.4. Future Work

Future work on this feature will address the current limitations that we have.

Linking of pet patients to their respective owners and appointments will be implemented. Tagging of the pet patients will also be implemented, as this is crucial to the searching of medical history of pets for the user.

4.5. Display List of PetPatients

4.5.1. Current Implemaentation

Since Veterinarians and their assistants have the need to view the PetPatients as a list and see how many PetPatients belong to the same Owner. It is necessary to implement the PetPatient List feature.

width:650

4.5.2. Design Consideration

  • Alternative 1: Use tab function to switch between PetPatientList and PersonList

    • Pros: The UI will be neat to see, saves more space for calendar view

    • Cons: The user will not be able to see both PetPatient and Owners at the same time.

  • ALternative 2: Implement another Panel to display PetPatients.

    • Pros: User will be able to see both lists at the same time

    • Cons: Takes up more space, making it difficult to display appointments in the future.

4.5.3. Current Limitations

More command and features relating to PetPatient List are to be properly developed, the tags of PetPatients are not properly organised.

4.5.4. Future Work

Implement the corresponding Add, Delete, List commands for petPatients and decide on the tags to be used for petPatients.

4.6. Show Appointments on calendar

4.6.1. Current Implementation

Since veterinarians and their assistants have the need to constantly check their schedule for upcoming appointments, a calender feature is required to show future appointments.

Third party API CalendarFX is used as a Java calendar frame to show Appointments.

width:650

4.6.2. Design Consideration

  • Alternative 1: Use iCalendar from Jfxtra library

    • Pros: Easy to implement, convenient to use. Can easily import from Jfxtra library.

    • Cons: UI styles are limited, the API is limited;

  • Alternative 2 (current choice): Implement CalendarFX API library.

    • Pros: Versatile APIs such as set style for each calendar, and much better looking UI than iCalendar.

    • Cons: Extra work required to integrate CalendarFX files into project, and may cause build problems if not implemented properly.

4.6.3. Current Limitations

There’s a known issue in CalendarFx, when switch from a year with appointments inside to a year without, the CalendarFx will still color the same appointment data despite there’s no entry on that date.

Users and developers should know that this issue is embedded inside CalendarFx, and hopefully can be resolved in future versions of CalendarFx.

4.6.4. Future Work

We may be able to make enhancements to the Medeina’s UI such as changing theme colour to match the UI colour of CalendarFX.

4.7. Finding a Contact or Pet Patient

The find function allows users to look for contacts or pet patients.

4.7.1. Current Implementation

4.7.2. Design Consideration

Aspect:
  • Alternative 1:

    • Pros:

    • Cons:

  • Alternative 2 (current choice):

    • Pros:

    • Cons:

4.7.3. Current Limitations

Users are unable to find appointment related elements as the Appointment listing function in the calendar is different from the listing function of the other classes of Person and PetPatient. As such, there is currently no implementation to find an appointment based on types or remarks, which may pose as inconvenience to veterinarians, should they want to search by a specific type of appointment or remark.

4.7.4. Future Considerations

In the future, Medeina might consider adding functions that allow for finding of appointments by types or remarks, as well as update the calendar accordingly with the results of the find command.

4.8. Listing Appointments of Different Views and Dates

The command allows users to list appointments based on the date that they wish to see, and the results are displayed via the API of CalendarFX.

4.8.1. Current Implementation

After Medeina implemented CalendarFX, users are able to view appointments at a specified date by clicking on the Calendar. However, as Medeina is a CLI-based application, users should not be required to move their mouse. Instead, users should be able to jump to certain dates to check appointments using the command line only.

ListAppointmentDayView
Figure 11. Day view of the Calendar obtained by the listappt -d command.

The implemented CalendarFX API consists of 4 different views: Day, Week, Month and Year views. Users should be able to get a specific requested view of a date, month, or year they wish to see.

The below diagram illustrates the interaction between the UI, Logic and Events components in the ListAppointment command.

SDforListAppointment
Figure 12. Sequence diagram for interactions between the different components upon running the listappt -y 2017 command.

ListAppointmentParser.java handles and separates the request of users based on a regular expression that captures the matching groups of options -d, -w, -m, -y. The parser then checks the remaining user input, and parses it into LocalDate, YearMonth and Year classes. Should there be no remaining user input after the option, the current date is obtained as the field. A new ListAppointmentCommand is created with the type (1 for year, 2 for month, 3 for week, 4 for date) as well as the parsed class.

In execute(), there is a switch that determines the type of command run based on the type obtained from the parser. The relevant functions to change the Calendar gets called based on the type, and an event gets called to handle the change. If an appointment is in the past, a check is done to determine whether there were appointments in the year of that requested date, so that users are not able to jump into years that should not have appointments (i.e. years before Medeina existed).

private CommandResult getYearView() throws NoAppointmentInYearException {
    if (year.isBefore(Year.now())) {
        if (!checkPastAppointment(year.getValue())) {
            throw new NoAppointmentInYearException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, MESSAGE_USAGE));
        }
    }

    EventsCenter.getInstance().post(new ChangeYearViewRequestEvent(year));
    return new CommandResult(String.format(MESSAGE_SUCCESS, "year"));
}

An event is then called to handle change the view with the specified date. The handler resides in CalendarWindow.java to be able to switch the calendarView to the specified requested view.

private void changeWeekView(LocalDate date) {
    WeekFields weekFields = WeekFields.SUNDAY_START;
    int week = date.get(weekFields.weekOfWeekBasedYear()) - 1;

    if (week == 0 && date.getMonthValue() == 12) {
        //wraparound
        week = 52;
        calendarView.showWeek(Year.of(date.getYear()), week);
    } else if (week == 0 && date.getMonthValue() == 1) {
        //wraparound
        LocalDate dateOfFirstJan = LocalDate.of(date.getYear(), 1, 1);
        if (dateOfFirstJan.getDayOfWeek().getValue() != 7) {
            week = 52;
            calendarView.showWeek(Year.of(date.getYear() - 1), week);
        } else {
            week = 53;
            calendarView.showWeek(Year.of(date.getYear() - 1), week);
        }
    } else {
        calendarView.showWeek(Year.of(date.getYear()), week);
    }
}

As the week view in calendarFX is different from the obtaining the week of year in the original Java API, there was a need to switch the week value obtained from LocalDate to fit the week value in the Calendar. Above illustrates the snippet of code used to convert from the value of the week obtained from LocalDate to fit the Calendar.

Upon a successful listing, a CommandResult(…​) class is called with a success message of the specified view.

4.8.2. Design Consideration

Aspect: Improving command usage
  • Alternative 1: Use a fixed date field.

    • Pros: Users only need to remember that a date in the format of YYYY-MM-DD is accepted for each listappt command.

    • Cons: Users have to type more than required, especially for Year and Month views.

  • Alternative 2 (current choice): Use a changing field: Year for Year view, YearMonth for Month view, LocalDate for Week and Day views.

    • Pros: Users do not need to type redundant information. A Year view will be in the format of YYYY while a Month view will be in the format of YYYY-MM or MM (with automatically allocated current year).

    • Cons: Users have to remember that Year view only accepts the year, while the Month view only accepts a year and month, or month. The Week and Day views will not accept just a year or year and month, but requires the specific date.

Aspect: Improving user productivity
  • Alternative 1 (current choice): Implement functions that requires users to type to switch views instead of clicking

    • Pros: Users do not need to switch between using a mouse and a keyboard, which increases productivity for users accustomed to the CLI based nature of Medeina.

    • Cons: Need to implement functions that help will change views (listappt or la command).

  • Alternative 2: Use buttons and clicks to switch a calendar than to manually input a command

    • Pros: There will be no need to implement any functions pertaining to ListAppointment.

    • Cons: Defeats the purpose of a CLI-based application.

4.9. Deletion and Force Deletion of Contact, Pet Patient and Appointment

The delete function allows its users to get rid of obsolete information.

4.9.1. Current Implementation

Medeina has multiple important classes to handle: Person, PetPatient and Appointment. As Medeina caters to veterinarians, there is a need for the ability to remove the mentioned classes. For example, an Appointment can be deleted should a contact decide not to go for the appointment anymore, a PetPatient should be deleted if a pet patient dies, and a Person should be deleted if a contact decides to immigrate permanently.

The below diagram illustrates the interaction between Logic and Model components during the deletion of a contact.

DeletePersonDiagramForDelete
Figure 13. Interaction of Logic and Model Components through the delete -o 1 command.

DeleteCommandParser.java handles and separates the deletion based on a regular expression, that captures the matching groups of options -o, -p, -a, -fp, -fo. Subsequently, the parser gets the Index from user input to determine the element to delete. The parser then creates a new DeleteCommand with the type (1 for contact, 2 for pet patient, 3 for appointment, 4 for force contact, 5 for force pet patient), as well as the Index.

In execute(), there is a switch that determines the type of command run based on the type obtained from the parser. The normal delete functions (types 1, 2, 3) subsequently calls the Model component to properly remove the element.

private CommandResult deleteAppointment() {
     //... code ...
     requireNonNull(appointmentToDelete);
     model.deleteAppointment(appointmentToDelete);
     //... code ...
     return new CommandResult(String.format(MESSAGE_DELETE_APPOINTMENT_SUCCESS, appointmentToDelete));
 }

However, for the force delete functions (types 4, 5), dependencies have to be removed before the element itself can be removed, as shown by the snippet of code from DeleteCommand.java below.

private CommandResult deleteForcePerson() {
    //... code ...

    List<PetPatient> petPatientsDeleted = model.deletePetPatientDependencies(personToDelete);
    List<Appointment> appointmentsDeleted = new ArrayList<>();
    for (PetPatient pp : petPatientsDeleted) {
        appointmentsDeleted.addAll(model.deleteAppointmentDependencies(pp));
        deleteDependenciesList += "\n" + (String.format(MESSAGE_DELETE_PET_PATIENT_SUCCESS, pp));
    }
    for (Appointment appointment : appointmentsDeleted) {
        deleteDependenciesList += "\n" + (String.format(MESSAGE_DELETE_APPOINTMENT_SUCCESS, appointment));
    }
    model.deletePerson(personToDelete);

    //... code ...

    return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete) + deleteDependenciesList);
}

It can be noted that pet patient dependencies are deleted before appointment dependencies. This is because of the dependency "hierachy" between the different elements. A pet patient is uniquely tied to a contact based on Nric, while an appointment is uniquely tied to a pet patient based on Nric and PetPatientName. As a result, pet patients must first be deleted before determining which appointments are to be deleted.

DeleteDependenciesForForce
Figure 14. Listing of relevant dependencies deleted upon a force deletion of a contact.

For each dependency deleted, it is stored in List<…​> so that the CommandResult(…​) returns all deleted dependencies as well as the main, deleted element.

4.9.2. Design Consideration

Aspect: Improving user friendliness
  • Alternative 1: Use different commands for different delete functions.

    • Pros: It is easier to implement. The command can just take in an Index without any options before.

    • Cons: Hard on users as they will have to type a different command for every type of delete (i.e. deleteperson, deletepetpatient etc.).

  • Alternative 2 (current choice): Use one overseeing delete command.

    • Pros: Users do not need to go through the hassle of trying to remember every different command of delete.

    • Cons: Extra work to determine the type of deletion (i.e. -a for Appointment, -p for PetPatient etc.).

Aspect: Ease of Use
  • Alternative 1: Have no force delete function.

    • Pros: There will be no need to implement functions to delete prior dependencies before a deletion is done. An exception can just be thrown if dependencies still exist.

    • Cons: Users will need to manually find and delete every dependency manually.

  • Alternative 2 (current choice): Have a force delete function that will delete all dependencies along with the element to be deleted.

    • Pros: Easier to use. Users do not need to manually find and delete all dependencies, it just gets deleted immediately if required.

    • Cons: Need to delete dependencies upon calling a force function. In addition, the dependencies deleted must be shown as well to inform users of all deleted elements.

4.9.3. Current Limitations

As of now, users are only capable of deleting an element based on its Index displayed in Medeina. This may pose as difficult for users if they want to delete an element based on the list displayed through the list command, especially if there is alot of data in Medeina.

4.9.4. Future Considerations

In the coming future, the Delete function can be altered such that it allows users to input other fields other than just Index, so that users do not need to get a list before deleting a particular element, especially if the user wants to delete an element that is not in the current listing (i.e. not on the listing after a find command).

4.10. Deletion and Force Deletion of Contact, Pet Patient and Appointment

The delete function allows its users to get rid of obsolete information.

4.10.1. Current Implementation

Medeina has multiple important classes to handle: Person, PetPatient and Appointment. As Medeina caters to veterinarians, there is a need for the ability to remove the mentioned classes. For example, an Appointment can be deleted should a contact decide not to go for the appointment anymore, a PetPatient should be deleted if a pet patient dies, and a Person should be deleted if a contact decides to immigrate permanently.

The below diagram illustrates the interaction between Logic and Model components during the deletion of a contact.

DeletePersonDiagramForDelete
Figure 15. Interaction of Logic and Model Components through the delete -o 1 command.

DeleteCommandParser.java handles and separates the deletion based on a regular expression, that captures the matching groups of options -o, -p, -a, -fp, -fo. Subsequently, the parser gets the Index from user input to determine the element to delete. The parser then creates a new DeleteCommand with the type (1 for contact, 2 for pet patient, 3 for appointment, 4 for force contact, 5 for force pet patient), as well as the Index.

In execute(), there is a switch that determines the type of command run based on the type obtained from the parser. The normal delete functions (types 1, 2, 3) subsequently calls the Model component to properly remove the element.

private CommandResult deleteAppointment() {
     //... code ...
     requireNonNull(appointmentToDelete);
     model.deleteAppointment(appointmentToDelete);
     //... code ...
     return new CommandResult(String.format(MESSAGE_DELETE_APPOINTMENT_SUCCESS, appointmentToDelete));
 }

However, for the force delete functions (types 4, 5), dependencies have to be removed before the element itself can be removed, as shown by the snippet of code from DeleteCommand.java below.

private CommandResult deleteForcePerson() {
    //... code ...

    List<PetPatient> petPatientsDeleted = model.deletePetPatientDependencies(personToDelete);
    List<Appointment> appointmentsDeleted = new ArrayList<>();
    for (PetPatient pp : petPatientsDeleted) {
        appointmentsDeleted.addAll(model.deleteAppointmentDependencies(pp));
        deleteDependenciesList += "\n" + (String.format(MESSAGE_DELETE_PET_PATIENT_SUCCESS, pp));
    }
    for (Appointment appointment : appointmentsDeleted) {
        deleteDependenciesList += "\n" + (String.format(MESSAGE_DELETE_APPOINTMENT_SUCCESS, appointment));
    }
    model.deletePerson(personToDelete);

    //... code ...

    return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete) + deleteDependenciesList);
}

It can be noted that pet patient dependencies are deleted before appointment dependencies. This is because of the dependency "hierachy" between the different elements. A pet patient is uniquely tied to a contact based on Nric, while an appointment is uniquely tied to a pet patient based on Nric and PetPatientName. As a result, pet patients must first be deleted before determining which appointments are to be deleted.

DeleteDependenciesForForce
Figure 16. Listing of relevant dependencies deleted upon a force deletion of a contact.

For each dependency deleted, it is stored in List<…​> so that the CommandResult(…​) returns all deleted dependencies as well as the main, deleted element.

4.10.2. Design Consideration

Aspect: Improving user-friendliness
  • Alternative 1: Use different commands for different delete functions.

    • Pros: It is easier to implement. The command can just take in an Index without any options before.

    • Cons: Hard on users as they will have to type a different command for every type of delete (i.e. deleteperson, deletepetpatient etc.).

  • Alternative 2 (current choice): Use one overseeing delete command.

    • Pros: Users do not need to go through the hassle of trying to remember every different command of delete.

    • Cons: Extra work to determine the type of deletion (i.e. -a for Appointment, -p for PetPatient etc.).

Aspect: Ease of Use
  • Alternative 1: Have no force delete function.

    • Pros: There will be no need to implement functions to delete prior dependencies before a deletion is done. An exception can just be thrown if dependencies still exist.

    • Cons: Users will need to manually find and delete every dependency manually.

  • Alternative 2 (current choice): Have a force delete function that will delete all dependencies along with the element to be deleted.

    • Pros: Easier to use. Users do not need to manually find and delete all dependencies, it just gets deleted immediately if required.

    • Cons: Need to delete dependencies upon calling a force function. In addition, the dependencies deleted must be shown as well to inform users of all deleted elements.

4.10.3. Current Limitations

As of now, users are only capable of deleting an element based on its Index displayed in Medeina. This may pose as difficult for users if they want to delete an element based on the list displayed through the list command, especially if there is alot of data in Medeina.

4.10.4. Future Considerations

In the coming future, the Delete function can be altered such that it allows users to input other fields other than just Index, so that users do not need to get a list before deleting a particular element, especially if the user wants to delete an element that is not in the current listing (i.e. not on the listing after a find command).

4.11. [Proposed] Data Encryption

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

4.12. 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 4.13, “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

4.13. Configuration

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

5. Documentation

We use asciidoc for writing documentation.

ℹ️
We chose asciidoc over Markdown because asciidoc, although a bit more complex than Markdown, provides more flexibility in formatting.

5.1. Editing Documentation

See UsingGradle.adoc to learn how to render .adoc files locally to preview the end result of your edits. Alternatively, you can download the AsciiDoc plugin for IntelliJ, which allows you to preview the changes you have made to your .adoc files in real-time.

5.2. Publishing Documentation

See UsingTravis.adoc to learn how to deploy GitHub Pages using Travis.

5.3. Converting Documentation to PDF format

We use Google Chrome for converting documentation to PDF format, as Chrome’s PDF engine preserves hyperlinks used in webpages.

Here are the steps to convert the project documentation files to PDF format.

  1. Follow the instructions in UsingGradle.adoc to convert the AsciiDoc files in the docs/ directory to HTML format.

  2. Go to your generated HTML files in the build/docs folder, right click on them and select Open withGoogle Chrome.

  3. Within Chrome, click on the Print option in Chrome’s menu.

  4. Set the destination to Save as PDF, then click Save to save a copy of the file in PDF format. For best results, use the settings indicated in the screenshot below.

chrome save as pdf
Figure 17. Saving documentation as PDF files in Chrome

6. Testing

6.1. Running Tests

There are three ways to run tests.

💡
The most reliable way to run tests is the 3rd one. The first two methods might fail some GUI tests due to platform/resolution-specific idiosyncrasies.

Method 1: Using IntelliJ JUnit test runner

  • To run all tests, right-click on the src/test/java folder and choose Run 'All Tests'

  • To run a subset of tests, you can right-click on a test package, test class, or a test and choose Run 'ABC'

Method 2: Using Gradle

  • Open a console and run the command gradlew clean allTests (Mac/Linux: ./gradlew clean allTests)

ℹ️
See UsingGradle.adoc for more info on how to run tests using Gradle.

Method 3: Using Gradle (headless)

Thanks to the TestFX library we use, our GUI tests can be run in the headless mode. In the headless mode, GUI tests do not show up on the screen. That means the developer can do other things on the Computer while the tests are running.

To run tests in headless mode, open a console and run the command gradlew clean headless allTests (Mac/Linux: ./gradlew clean headless allTests)

6.2. Types of tests

We have two types of tests:

  1. GUI Tests - These are tests involving the GUI. They include,

    1. System Tests that test the entire App by simulating user actions on the GUI. These are in the systemtests package.

    2. Unit tests that test the individual components. These are in seedu.address.ui package.

  2. Non-GUI Tests - These are tests not involving the GUI. They include,

    1. Unit tests targeting the lowest level methods/classes.
      e.g. seedu.address.commons.StringUtilTest

    2. Integration tests that are checking the integration of multiple code units (those code units are assumed to be working).
      e.g. seedu.address.storage.StorageManagerTest

    3. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.
      e.g. seedu.address.logic.LogicManagerTest

6.3. Troubleshooting Testing

Problem: HelpWindowTest fails with a NullPointerException.

  • Reason: One of its dependencies, UserGuide.html in src/main/resources/docs is missing.

  • Solution: Execute Gradle task processResources.

7. Dev Ops

7.1. Build Automation

See UsingGradle.adoc to learn how to use Gradle for build automation.

7.2. Continuous Integration

We use Travis CI and AppVeyor to perform Continuous Integration on our projects. See UsingTravis.adoc and UsingAppVeyor.adoc for more details.

7.3. Coverage Reporting

We use Coveralls to track the code coverage of our projects. See UsingCoveralls.adoc for more details.

7.4. Documentation Previews

When a pull request has changes to asciidoc files, you can use Netlify to see a preview of how the HTML version of those asciidoc files will look like when the pull request is merged. See UsingNetlify.adoc for more details.

7.5. Making a Release

Here are the steps to create a new release.

  1. Update the version number in MainApp.java.

  2. Generate a JAR file using Gradle.

  3. Tag the repo with the version number. e.g. v0.1

  4. Create a new release using GitHub and upload the JAR file you created.

7.6. Managing Dependencies

A project often depends on third-party libraries. For example, Medeina depends on the Jackson library for XML parsing. Managing these dependencies can be automated using Gradle. For example, Gradle can download the dependencies automatically, which is better than these alternatives.
a. Include those libraries in the repo (this bloats the repo size)
b. Require developers to download those libraries manually (this creates extra work for developers)

Appendix A: Suggested Programming Tasks to Get Started

Suggested path for new programmers:

  1. First, add small local-impact (i.e. the impact of the change does not go beyond the component) enhancements to one component at a time. Some suggestions are given in Section A.1, “Improving each component”.

  2. Next, add a feature that touches multiple components to learn how to implement an end-to-end feature across all components. Section A.2, “Creating a new command: remark explains how to go about adding such a feature.

A.1. Improving each component

Each individual exercise in this section is component-based (i.e. you would not need to modify the other components to get it to work).

Logic component

Scenario: You are in charge of logic. During dog-fooding, your team realize that it is troublesome for the user to type the whole command in order to execute a command. Your team devise some strategies to help cut down the amount of typing necessary, and one of the suggestions was to implement aliases for the command words. Your job is to implement such aliases.

💡
Do take a look at Section 3.3, “Logic component” before attempting to modify the Logic component.
  1. Add a shorthand equivalent alias for each of the individual commands. For example, besides typing clear, the user can also type c to remove all persons in the list.

    • Hints

    • Solution

      • Modify the switch statement in AddressBookParser#parseCommand(String) such that both the proper command word and alias can be used to execute the same intended command.

      • Add new tests for each of the aliases that you have added.

      • Update the user guide to document the new aliases.

      • See this PR for the full solution.

Model component

Scenario: You are in charge of model. One day, the logic-in-charge approaches you for help. He wants to implement a command such that the user is able to remove a particular tag from everyone in the address book, but the model API does not support such a functionality at the moment. Your job is to implement an API method, so that your teammate can use your API to implement his command.

💡
Do take a look at Section 3.4, “Model component” before attempting to modify the Model component.
  1. Add a removeTag(Tag) method. The specified tag will be removed from everyone in Medeina’s address book.

    • Hints

      • The Model and the AddressBook API need to be updated.

      • Think about how you can use SLAP to design the method. Where should we place the main logic of deleting tags?

      • Find out which of the existing API methods in AddressBook and Person classes can be used to implement the tag removal logic. AddressBook allows you to update a person, and Person allows you to update the tags.

    • Solution

      • Implement a removeTag(Tag) method in AddressBook. Loop through each person, and remove the tag from each person.

      • Add a new API method deleteTag(Tag) in ModelManager. Your ModelManager should call AddressBook#removeTag(Tag).

      • Add new tests for each of the new public methods that you have added.

      • See this PR for the full solution.

        • The current codebase has a flaw in tags management. Tags no longer in use by anyone may still exist on the AddressBook. This may cause some tests to fail. See issue #753 for more information about this flaw.

        • The solution PR has a temporary fix for the flaw mentioned above in its first commit.

Ui component

Scenario: You are in charge of ui. During a beta testing session, your team is observing how the users use your address book application. You realize that one of the users occasionally tries to delete non-existent tags from a contact, because the tags all look the same visually, and the user got confused. Another user made a typing mistake in his command, but did not realize he had done so because the error message wasn’t prominent enough. A third user keeps scrolling down the list, because he keeps forgetting the index of the last person in the list. Your job is to implement improvements to the UI to solve all these problems.

💡
Do take a look at Section 3.2, “UI component” before attempting to modify the UI component.
  1. Use different colors for different tags inside person cards. For example, friends tags can be all in brown, and colleagues tags can be all in yellow.

    Before

    getting started ui tag before

    After

    getting started ui tag after
    • Hints

      • The tag labels are created inside the PersonCard constructor (new Label(tag.tagName)). JavaFX’s Label class allows you to modify the style of each Label, such as changing its color.

      • Use the .css attribute -fx-background-color to add a color.

      • You may wish to modify DarkTheme.css to include some pre-defined colors using css, especially if you have experience with web-based css.

    • Solution

      • You can modify the existing test methods for PersonCard 's to include testing the tag’s color as well.

      • See this PR for the full solution.

        • The PR uses the hash code of the tag names to generate a color. This is deliberately designed to ensure consistent colors each time the application runs. You may wish to expand on this design to include additional features, such as allowing users to set their own tag colors, and directly saving the colors to storage, so that tags retain their colors even if the hash code algorithm changes.

  2. Modify NewResultAvailableEvent such that ResultDisplay can show a different style on error (currently it shows the same regardless of errors).

    Before

    getting started ui result before

    After

    getting started ui result after
  3. Modify the StatusBarFooter to show the total number of people in the address book.

    Before

    getting started ui status before

    After

    getting started ui status after
    • Hints

      • StatusBarFooter.fxml will need a new StatusBar. Be sure to set the GridPane.columnIndex properly for each StatusBar to avoid misalignment!

      • StatusBarFooter needs to initialize the status bar on application start, and to update it accordingly whenever the address book is updated.

    • Solution

Storage component

Scenario: You are in charge of storage. For your next project milestone, your team plans to implement a new feature of saving the address book to the cloud. However, the current implementation of the application constantly saves the address book after the execution of each command, which is not ideal if the user is working on limited internet connection. Your team decided that the application should instead save the changes to a temporary local backup file first, and only upload to the cloud after the user closes the application. Your job is to implement a backup API for the address book storage.

💡
Do take a look at Section 3.5, “Storage component” before attempting to modify the Storage component.
  1. Add a new method backupAddressBook(ReadOnlyAddressBook), so that the address book can be saved in a fixed temporary location.

A.2. Creating a new command: remark

By creating this command, you will get a chance to learn how to implement a feature end-to-end, touching all major components of the app.

Scenario: You are a software maintainer for addressbook, as the former developer team has moved on to new projects. The current users of your application have a list of new feature requests that they hope the software will eventually have. The most popular request is to allow adding additional comments/notes about a particular contact, by providing a flexible remark field for each contact, rather than relying on tags alone. After designing the specification for the remark command, you are convinced that this feature is worth implementing. Your job is to implement the remark command.

A.2.1. Description

Edits the remark for a person specified in the INDEX.
Format: remark INDEX r/[REMARK]

Examples:

  • remark 1 r/Likes to drink coffee.
    Edits the remark for the first person to Likes to drink coffee.

  • remark 1 r/
    Removes the remark for the first person.

A.2.2. Step-by-step Instructions

[Step 1] Logic: Teach the app to accept 'remark' which does nothing

Let’s start by teaching the application how to parse a remark command. We will add the logic of remark later.

Main:

  1. Add a RemarkCommand that extends UndoableCommand. Upon execution, it should just throw an Exception.

  2. Modify AddressBookParser to accept a RemarkCommand.

Tests:

  1. Add RemarkCommandTest that tests that executeUndoableCommand() throws an Exception.

  2. Add new test method to AddressBookParserTest, which tests that typing "remark" returns an instance of RemarkCommand.

[Step 2] Logic: Teach the app to accept 'remark' arguments

Let’s teach the application to parse arguments that our remark command will accept. E.g. 1 r/Likes to drink coffee.

Main:

  1. Modify RemarkCommand to take in an Index and String and print those two parameters as the error message.

  2. Add RemarkCommandParser that knows how to parse two arguments, one index and one with prefix 'r/'.

  3. Modify AddressBookParser to use the newly implemented RemarkCommandParser.

Tests:

  1. Modify RemarkCommandTest to test the RemarkCommand#equals() method.

  2. Add RemarkCommandParserTest that tests different boundary values for RemarkCommandParser.

  3. Modify AddressBookParserTest to test that the correct command is generated according to the user input.

[Step 3] Ui: Add a placeholder for remark in PersonCard

Let’s add a placeholder on all our PersonCard s to display a remark for each person later.

Main:

  1. Add a Label with any random text inside PersonListCard.fxml.

  2. Add FXML annotation in PersonCard to tie the variable to the actual label.

Tests:

  1. Modify PersonCardHandle so that future tests can read the contents of the remark label.

[Step 4] Model: Add Remark class

We have to properly encapsulate the remark in our Person class. Instead of just using a String, let’s follow the conventional class structure that the codebase already uses by adding a Remark class.

Main:

  1. Add Remark to model component (you can copy from Address, remove the regex and change the names accordingly).

  2. Modify RemarkCommand to now take in a Remark instead of a String.

Tests:

  1. Add test for Remark, to test the Remark#equals() method.

[Step 5] Model: Modify Person to support a Remark field

Now we have the Remark class, we need to actually use it inside Person.

Main:

  1. Add getRemark() in Person.

  2. You may assume that the user will not be able to use the add and edit commands to modify the remarks field (i.e. the person will be created without a remark).

  3. Modify SampleDataUtil to add remarks for the sample data (delete your addressBook.xml so that the application will load the sample data when you launch it.)

[Step 6] Storage: Add Remark field to XmlAdaptedPerson class

We now have Remark s for Person s, but they will be gone when we exit the application. Let’s modify XmlAdaptedPerson to include a Remark field so that it will be saved.

Main:

  1. Add a new Xml field for Remark.

Tests:

  1. Fix invalidAndValidPersonAddressBook.xml, typicalPersonsAddressBook.xml, validAddressBook.xml etc., such that the XML tests will not fail due to a missing <remark> element.

[Step 6b] Test: Add withRemark() for PersonBuilder

Since Person can now have a Remark, we should add a helper method to PersonBuilder, so that users are able to create remarks when building a Person.

Tests:

  1. Add a new method withRemark() for PersonBuilder. This method will create a new Remark for the person that it is currently building.

  2. Try and use the method on any sample Person in TypicalPersons.

[Step 7] Ui: Connect Remark field to PersonCard

Our remark label in PersonCard is still a placeholder. Let’s bring it to life by binding it with the actual remark field.

Main:

  1. Modify PersonCard's constructor to bind the Remark field to the Person 's remark.

Tests:

  1. Modify GuiTestAssert#assertCardDisplaysPerson(…​) so that it will compare the now-functioning remark label.

[Step 8] Logic: Implement RemarkCommand#execute() logic

We now have everything set up…​ but we still can’t modify the remarks. Let’s finish it up by adding in actual logic for our remark command.

Main:

  1. Replace the logic in RemarkCommand#execute() (that currently just throws an Exception), with the actual logic to modify the remarks of a person.

Tests:

  1. Update RemarkCommandTest to test that the execute() logic works.

A.2.3. Full Solution

See this PR for the step-by-step solution.

Appendix B: Product Scope

Target user profile:

  • tech-savvy veterinarians and their assistants

  • can type relatively fast while maintaining accuracy

  • requires using the desktop in the workplace

  • requires CLI applications for efficiency

  • provide veterinary services to domestic animals in Singapore

  • has to manage a significant number of pet patients

  • requires the information kept to generally be non-volatile

  • needs to search through amounts of data for information

Value proposition: all-in-one vet assistant app that can view and make appointments and search for information

Feature contribution:

Name Major enhancement(s) Minor enhancement(s)

Jacqueline Cheong

  • Autocomplete

To enhance user experience and usage efficiency of the CLI by providing autocomplete suggestions

  • Add command

A single add command with options to add a contact, pet patient and appointment to Medeina. Users don’t have to remember multiple commands performing similar functions. The new add command also enables the user to all 3 objects at one go to reduce typing.

  • Add support to change theme (persistent beyond app restart)

This allows Vets to change the application’s appearance to better suit their preferences and working environment (e.g. dark theme for night time)

Chia Le Jing

PetPatient class and all its relevant features

Commands such as add, edit, delete, find. Also includes the storage of pet patient’s data into the associated .xml file.

Implement backup function for local databases and the cloud (for v2.0)

Allows local files to be backed up with the latest copy (in case of corruption of data). Also allows data to be backed up to the cloud for future use.

Wynona Kaan

Find by Contact or Pet Patient

Allows for finding of contacts or pet patients based on a particular field or a combination of fields allowed.

Delete Contact, Pet Patient or Appointment

Allows for deletion of contacts, pet patients and appointments, as well as force deletion of contacts and pet patients that deletes all relevant dependencies along with the element deleted.

Appointment class, storing and listing of appointments

Create a new class for to handle appointments. Allows for storage so that appointments can be stored in the .xml file and persist beyond application restart. Allows for listing of appointments in specific requested views of requested dates in CalendarFX.

Peng Xuanchang

Integrating CalenderFX as framework for Calender view

Vets and their assistants will be able to see their appointments in calender view integrated in the software.

Add NRIC field in Owner’s profile

The NRIC field will help the veterinarians and their assistants to better locate an owner using their unique ID.

Appendix C: 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 command syntax, or how to use the App

* * *

user

add a pet patient

register its information

* * *

user

find a pet patient by name

easily locate its information without having to go through a long list of pet patients

* * *

user

add appointment

schedule meetings with pet patients and their owners

* * *

user

edit pet owner’s contact information

update any change in contact information (e.g. changed hand phone number, change of address)

* * *

user

basic tags to be assigned automatically

type lesser (e.g. when adding a pet owner, the "Person" tag should be assigned by default)

* * *

user

list out appointments for next day

prepare for the required procedures/diagnosis/consultation

* * *

user

classify appointments by types

better organize a long list of appointments

* * *

user

cancel an appointment

make space in schedule for other things

* * *

user

see upcoming appointments

prepare/plan in advance

* * *

user

see a list of today’s appointment

check on today’s schedule

* * *

user

filter pet patients by species and blood type

contact them for blood donation during emergencies

* * *

user

reschedule an appointment

make time for emergency situations

* * *

user

search by pet owner’s name

retrieve a list of pet patients under a particular owner

* * *

user

add a pet owner

maintain contact information and register a pet patient under him or her

* * *

user

add in owner details such as contact number

contact them when needed

* * *

user

update pet patients' information

* * *

user

see pet owner’s name when checking pet patients' profile

know who it belongs to

* * *

user

delete a pet patient after certain period

remove entries that I no longer need

* * *

user

have a simple and intuitive command line interface

maximize workflow efficiency

* *

user

change the theme of the application

better suit my preference

* *

user

log in with password

protect my pet patients' and their respective owners' information

* *

user

update status of pet patient (living, deceased)

know the number of pets I am managing now

* *

user

check who is my assistant for the day/particular pet patient

brief them in advance

* *

user

check services consumed for a particular appointment

know what a pet patient has gone through

*

user

create and modify tags

standardize tags used in the application

*

user

have reminders sms sent to pet owners automatically 2 days before appointment

*

user

update my status

be recognized as an official vet after my training

*

user

transfer a pet patient from my clinic to another in case of emergency

*

user

manage the "rooms" in hospital

make space for newly hospitalized pet patient

*

user

search for a pet patient’s medical history

know the next step of treatment

*

user with many pet patients in the address book

sort pet patients by name

locate a pet patient easily

{More to be added}

Appendix D: Use Cases

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

Use case: list appointments

MSS

  1. User requests to view appointments for current month

  2. Medeina updates calendarFx to show appointments for the current month

    Use case ends.

Extensions

  • 2a. There are no appointments for the month.

    Use case ends.

    Use case: Update pet patient’s point of contact

MSS

  1. User requests to find a pet patient with the name "Joseph"

  2. Medeina shows a list of pet patients with the name "Joseph" in the pet patient card panel and updates the contacts card panel with their point of contact.

  3. User requests to modify the pet patient’s point of contact

  4. Medeina shows the pet patient’s updated information

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. Medeina shows an error message.

      Use case resumes at step 2.

  • 3b. The given command is invalid.

    • 3b1. Medeina shows the correct command usage to edit pet patient’s information.

      Use case resumes at step 2.

Use case: Retrieve pet patient information under a particular contact

MSS

  1. User requests to find a contact named "Mavis"

  2. Medeina shows a list of contacts with "Mavis" as part of their name and updates the pet patient card panel with pet patients under them

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

Use case: Add tag(s) to a contact

MSS

  1. User requests to find an contacts with the name "Mavis"

  2. Medeina shows a list of contacts with the name "Mavis" and updates the pet patient card panel with pet patients under them

  3. User requests to add tags to a specific owner on the list

  4. Medeina shows updated owner information

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. Medeina shows an error message.

      Use case resumes at step 2.

  • 3b. The given tag(s) is/are invalid.

    • 3b1. Medeina shows an error message.

      Use case resumes at step 2.

Appendix E: Non Functional Requirements

  1. The system should work on Windows, Linux and macOS as long as it has Java 1.8.0_60 or higher installed.

  2. A user (vet or vet assistant) with above average typing speed for regular English text (i.e. not code, not system administrative commands) should be able to accomplish most of the tasks faster using commands than using the mouse.

  3. The system should be accessible, even without any Internet connection (or with poor Internet connection).

  4. The system should be able to hold the information of at least 1000 patients (pets) and their respective owners without noticeable sluggishness in performance for typical usage.

  5. The system should be stable (runs without crashing, even for extended hours) and responsive (with a maximum lag of 2 seconds) due to the possibility of patient emergencies.

  6. The system should be reliable and accurate (i.e. information keyed in is guaranteed to be saved, information retrieved is guaranteed to be accurate based on what was keyed in previously).

  7. The system must have sufficient security (such as password protection / encrypted storage file) to protect the confidentiality of the patients (pets) and their respective owners. This is also to ensure compliance with PDPA.

  8. Patient’s and owner’s information should be easily and accurately backed up, with zero errors in the information.

  9. Restoring patient’s and their respective owner’s information should be an easy process.

  10. The system should have sufficient commands / functions to ensure that information can be maintained and managed easily. Basic operations such as add, delete, find, update must be included for patients and their respective owners.

{More to be added}

Appendix F: Glossary

Mainstream OS

Windows, Linux, Unix, OS-X

Assistants

People who help Veterinarians (receptionist, technicians etc.)

CLI

Command Line Interface

Pet Patients

Domestic animals which seek veterinary services

Person

To refer to contacts in the implementation of Medeina

Contact

To refer to owners of pet patients

Singleton

A design pattern in programming

Appendix G: Product Survey

Product Name

Author: …​

Pros:

  • …​

  • …​

Cons:

  • …​

  • …​

Appendix H: 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.

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

H.2. Change theme

  1. dark theme

    1. Type "theme dark" in the command box to switch to dark theme.

    2. Re-launch the app by double-clicking the jar file.
      Expected: The app is using dark theme. The change of theme persists beyond app restart.

H.3. Autocomplete

  1. Command word

    1. In an empty command box (with no user input), type a space. You should see a drop down list of commands supported by Medeina.

    2. Continue typing spaces in the command box. The same drop down list of command words will be suggested.

  2. Prefixes

    1. Type "add " you should see a list of prefixes supported by Medeina.

    2. Type "edit " you should see a list of prefixes supported by Medeina.

    3. Type "find " you should see a list of prefixes supported by Medeina.

    4. Type "delete " you should see a list of prefixes supported by Medeina.

    5. Type "listappt " you should see a list of prefixes supported by Medeina.

    6. There will be no prefixes suggested for all other preceeding words e.g. "sdfkljsdlkfjs ", "help ".

  3. Options

    1. Type "add -" you should see a list of options (starting with "-") supported by Medeina.

    2. Type "edit -" you should see a list of options (starting with "-") supported by Medeina.

    3. Type "find -" you should see a list of options (starting with "-") supported by Medeina.

    4. Type "delete -" you should see a list of options (starting with "-") supported by Medeina.

    5. Type "listappt -" you should see a list of options (starting with "-") supported by Medeina.

    6. There will be no options suggested for all other preceeding words e.g. "sdfkljsdlkfjs -", "help -".

  4. Species, breed, colour and blood type

    1. Typing s/, b/, c/ and bt/ after a word (and a space) in the command box, will show their respective suggestions.

  5. Pet patient names

    1. Type "add -a -o -p n/" and you will see a list of pet patient name suggestions (cap at 13).

    2. Type "add -p n/" and there will be no pet patient name suggestions.

  6. NRIC

    1. Type "add -p -o nr/" and you will see a list of NRIC suggestions (cap at 13).

    2. Type "add -p n/Mikey s/Cat b/Persian c/Calico bt/A -o nr/" and you will see a list of NRIC suggestions (cap at 13).

    3. Type "add -p n/Mikey s/Cat b/Persian c/Calico bt/A -o nr/T" and you will see a list of NRIC suggestions starting with "T" (cap at 13).

    4. Type "edit 1 -p nr/" to see a list of NRIC suggestions (cap at 13).

    5. Type "edit 1 -p n/hello nr/" to see a list of NRIC suggestions (cap at 13).

    6. Type "find -o nr/" to see a list of NRIC suggestions (cap at 13).

  7. Toggle on/off

    1. Press F2 when the command box is in focus to off/on autocomplete.

H.4. Adding contact, pet patient, appointment

H.5. 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 …​ }

H.6. Listing owners and petPatients

  1. Listing out all owners and petPatients

    1. Prerequisites: Conduct find command. More than one person or petPatient in the lists.

    2. Testcase: find -o n/Alex + list
      Expected: Medeina will display the located person and then list out all owners and petPatients in Medeina’s storage.

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