Skip to content

Commit

Permalink
Merge pull request #54 from afroneth/update-devguide
Browse files Browse the repository at this point in the history
Change remaining references of Address Book to CliniCal
  • Loading branch information
ktaekwon000 authored Sep 27, 2020
2 parents c645ca0 + 3efea9b commit 5e828ed
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 56 deletions.
44 changes: 22 additions & 22 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The `UI` component,
**API** :
[`Logic.java`](https://github.com/AY2021S1-CS2103T-W11-4/tp/tree/master/src/main/java/seedu/address/logic/Logic.java)

1. `Logic` uses the `AddressBookParser` class to parse the user command.
1. `Logic` uses the `CliniCalParser` class to parse the user command.
1. This results in a `Command` object which is executed by the `LogicManager`.
1. The command execution can affect the `Model` (e.g. adding a patient).
1. The result of the command execution is encapsulated as a `CommandResult` object which is passed back to the `Ui`.
Expand All @@ -102,12 +102,12 @@ Given below is the Sequence Diagram for interactions within the `Logic` componen
The `Model`,

* stores a `UserPref` object that represents the user’s preferences.
* stores the address book data.
* stores the CliniCal application data.
* exposes an unmodifiable `ObservableList<Patient>` 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.


<div markdown="span" class="alert alert-info">:information_source: **Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `AddressBook`, which `Patient` references. This allows `AddressBook` to only require one `Tag` object per unique `Tag`, instead of each `Patient` needing their own `Tag` object.<br>
<div markdown="span" class="alert alert-info">:information_source: **Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `CliniCal` application, which `Patient` references. This allows `CliniCal` to only require one `Tag` object per unique `Tag`, instead of each `Patient` needing their own `Tag` object.<br>
![BetterModelClassDiagram](images/BetterModelClassDiagram.png)

</div>
Expand All @@ -121,7 +121,7 @@ The `Model`,

The `Storage` component,
* can save `UserPref` objects in json format and read it back.
* can save the address book data in json format and read it back.
* can save the patient data in json format and read it back.

### Common classes

Expand All @@ -137,37 +137,37 @@ This section describes some noteworthy details on how certain features are imple

#### Proposed Implementation

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:
The proposed undo/redo mechanism is facilitated by `VersionedCliniCal`. It extends `CliniCal` with an undo/redo history, stored internally as an `CliniCalStateList` 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.
* `VersionedCliniCal#commit()` — Saves the current CliniCal application state in its history.
* `VersionedCliniCal#undo()` — Restores the previous CliniCal application state from its history.
* `VersionedCliniCal#redo()` — Restores a previously undone CliniCal application state from its history.

These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively.
These operations are exposed in the `Model` interface as `Model#commitCliniCal()`, `Model#undoCliniCal()` and `Model#redoCliniCal()` 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 1. The user launches the application for the first time. The `VersionedCliniCal` will be initialized with the initial CliniCal application state, and the `currentStatePointer` pointing to that single CliniCal application state.

![UndoRedoState0](images/UndoRedoState0.png)

Step 2. The user executes `delete 5` command to delete the 5th patient 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 2. The user executes `delete 5` command to delete the 5th patient in the patient data list. The `delete` command calls `Model#commitCliniCal()`, causing the modified state of the CliniCal application after the `delete 5` command executes to be saved in the `CliniCalStateList`, and the `currentStatePointer` is shifted to the newly inserted CliniCal application state.

![UndoRedoState1](images/UndoRedoState1.png)

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

![UndoRedoState2](images/UndoRedoState2.png)

<div markdown="span" class="alert alert-info">:information_source: **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`.
<div markdown="span" class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Model#commitCliniCal()`, so the CliniCal application state will not be saved into the `CliniCalStateList`.

</div>

Step 4. The user now decides that adding the patient 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.
Step 4. The user now decides that adding the patient was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoCliniCal()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous CliniCal application state, and restores the CliniCal application to that state.

![UndoRedoState3](images/UndoRedoState3.png)

<div markdown="span" class="alert alert-info">:information_source: **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
<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index 0, pointing to the initial CliniCal state, then there are no previous CliniCal states to restore. The `undo` command uses `Model#canUndoCliniCal()` to check if this is the case. If so, it will return an error to the user rather
than attempting to perform the undo.

</div>
Expand All @@ -180,17 +180,17 @@ The following sequence diagram shows how the undo operation works:

</div>

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.
The `redo` command does the opposite — it calls `Model#redoCliniCal()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the CliniCal application to that state.

<div markdown="span" class="alert alert-info">:information_source: **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.
<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index `CliniCalStateList.size() - 1`, pointing to the latest CliniCal application state, then there are no undone CliniCal states to restore. The `redo` command uses `Model#canRedoCliniCal()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.

</div>

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 5. The user then decides to execute the command `list`. Commands that do not modify the CliniCal application, such as `list`, will usually not call `Model#commitCliniCal()`, `Model#undoCliniCal()` or `Model#redoCliniCal()`. Thus, the `CliniCalStateList` remains unchanged.

![UndoRedoState4](images/UndoRedoState4.png)

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.
Step 6. The user executes `clear`, which calls `Model#commitCliniCal()`. Since the `currentStatePointer` is not pointing at the end of the `CliniCalStateList`, all CliniCal application 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.

![UndoRedoState5](images/UndoRedoState5.png)

Expand All @@ -202,7 +202,7 @@ The following activity diagram summarizes what happens when a user executes a ne

##### Aspect: How undo & redo executes

* **Alternative 1 (current choice):** Saves the entire address book.
* **Alternative 1 (current choice):** Saves the entire patient details in CliniCal application.
* Pros: Easy to implement.
* Cons: May have performance issues in terms of memory usage.

Expand Down Expand Up @@ -366,7 +366,7 @@ testers are expected to do more *exploratory* testing.

1. Download the jar file and copy into an empty folder

1. Double-click the jar file Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.
1. Double-click the jar file Expected: Shows the GUI with a set of sample patient contact details. The window size may not be optimum.

1. Saving window preferences

Expand All @@ -384,7 +384,7 @@ testers are expected to do more *exploratory* testing.
1. Prerequisites: List all patients using the `list` command. Multiple patients in the list.

1. Test case: `delete 1`<br>
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.
Expected: First patient is deleted from the list. Details of the deleted patient shown in the status message. Timestamp in the status bar is updated.

1. Test case: `delete 0`<br>
Expected: No patient is deleted. Error details shown in the status message. Status bar remains the same.
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ public void init() throws Exception {
}

/**
* Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code userPrefs}. <br>
* The data from the sample address book will be used instead if {@code storage}'s address book is not found,
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
* Returns a {@code ModelManager} with the data from {@code storage}'s CliniCal application
* and {@code userPrefs}. <br>
* The data from the sample CliniCal application will be used instead if {@code storage}'s CliniCal application
* is not found, or an empty CliniCal application with zero patient data will be used instead if errors occur when
* reading {@code storage}'s CliniCal application.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
Optional<ReadOnlyCliniCal> cliniCalOptional;
Expand Down Expand Up @@ -173,7 +175,7 @@ public void start(Stage primaryStage) {

@Override
public void stop() {
logger.info("============================ [ Stopping Address Book ] =============================");
logger.info("============================ [ Stopping CliniCal ] =============================");
try {
storage.saveUserPrefs(model.getUserPrefs());
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface Logic {
ObservableList<Patient> getFilteredPatientList();

/**
* Returns the user prefs' address book file path.
* Returns the user prefs' CliniCal application file path.
*/
Path getCliniCalFilePath();

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import seedu.address.model.patient.Patient;

/**
* Adds a patient to the address book.
* Adds a patient to the CliniCal application.
*/
public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a patient to the address book. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a patient to the list of patients. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
Expand All @@ -34,7 +34,7 @@ public class AddCommand extends Command {
+ PREFIX_TAG + "owesMoney";

public static final String MESSAGE_SUCCESS = "New patient added: %1$s";
public static final String MESSAGE_DUPLICATE_PATIENT = "This patient already exists in the address book";
public static final String MESSAGE_DUPLICATE_PATIENT = "This patient already exists in the list of patients";

private final Patient toAdd;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
public static final String MESSAGE_SUCCESS = "All patient data has been cleared!";


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.address.model.patient.Patient;

/**
* Deletes a patient identified using it's displayed index from the address book.
* Deletes a patient identified using it's displayed index from the list of patient in CliniCal.
*/
public class DeleteCommand extends Command {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import seedu.address.model.tag.Tag;

/**
* Edits the details of an existing patient in the address book.
* Edits the details of an existing patient in the CliniCal application.
*/
public class EditCommand extends Command {

Expand All @@ -48,7 +48,7 @@ public class EditCommand extends Command {

public static final String MESSAGE_EDIT_PATIENT_SUCCESS = "Edited Patient: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
public static final String MESSAGE_DUPLICATE_PATIENT = "This patient already exists in the address book.";
public static final String MESSAGE_DUPLICATE_PATIENT = "This patient already exists in the list of patients.";

private final Index index;
private final EditPatientDescriptor editPatientDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";
public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting CliniCal as requested ...";

@Override
public CommandResult execute(Model model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import seedu.address.model.patient.NameContainsKeywordsPredicate;

/**
* Finds and lists all patients in address book whose name contains any of the argument keywords.
* Finds and lists all patients in CliniCal whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import seedu.address.model.Model;

/**
* Lists all patients in the address book to the user.
* Lists all patients in the CliniCal application to the user.
*/
public class ListCommand extends Command {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/CliniCal.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import seedu.address.model.patient.UniquePatientList;

/**
* Wraps all data at the address-book level
* Wraps all data at the CliniCal application level
* Duplicates are not allowed (by .isSamePatient comparison)
*/
public class CliniCal implements ReadOnlyCliniCal {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,45 @@ public interface Model {
void setGuiSettings(GuiSettings guiSettings);

/**
* Returns the user prefs' address book file path.
* Returns the user prefs' CliniCal application file path.
*/
Path getCliniCalFilePath();

/**
* Sets the user prefs' address book file path.
* Sets the user prefs' CliniCal application file path.
*/
void setCliniCalFilePath(Path cliniCalFilePath);

/**
* Replaces address book data with the data in {@code cliniCal}.
* Replaces CliniCal application data with the data in {@code cliniCal}.
*/
void setCliniCal(ReadOnlyCliniCal cliniCal);

/** Returns the CliniCal */
ReadOnlyCliniCal getCliniCal();

/**
* Returns true if a patient with the same identity as {@code patient} exists in the address book.
* Returns true if a patient with the same identity as {@code patient} exists in the CliniCal application.
*/
boolean hasPatient(Patient patient);

/**
* Deletes the given patient.
* The patient must exist in the address book.
* The patient must exist in the CliniCal application.
*/
void deletePatient(Patient target);

/**
* Adds the given patient.
* {@code patient} must not already exist in the address book.
* {@code patient} must not already exist in the CliniCal application.
*/
void addPatient(Patient patient);

/**
* Replaces the given patient {@code target} with {@code editedPatient}.
* {@code target} must exist in the address book.
* {@code target} must exist in the CliniCal application.
* The patient identity of {@code editedPatient} must not be the same as another existing patient
* in the address book.
* in the CliniCal application.
*/
void setPatient(Patient target, Patient editedPatient);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import seedu.address.model.patient.Patient;

/**
* Represents the in-memory model of the address book data.
* Represents the in-memory model of the CliniCal application data.
*/
public class ModelManager implements Model {
private static final Logger logger = LogsCenter.getLogger(ModelManager.class);
Expand All @@ -30,7 +30,7 @@ public ModelManager(ReadOnlyCliniCal cliniCal, ReadOnlyUserPrefs userPrefs) {
super();
requireAllNonNull(cliniCal, userPrefs);

logger.fine("Initializing with address book: " + cliniCal + " and user prefs " + userPrefs);
logger.fine("Initializing with CliniCal application: " + cliniCal + " and user prefs " + userPrefs);

this.cliniCal = new CliniCal(cliniCal);
this.userPrefs = new UserPrefs(userPrefs);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/ReadOnlyCliniCal.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import seedu.address.model.patient.Patient;

/**
* Unmodifiable view of an address book
* Unmodifiable view of the CliniCal application
*/
public interface ReadOnlyCliniCal {

Expand Down
Loading

0 comments on commit 5e828ed

Please sign in to comment.