Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dg improvements v1.4 #233

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,36 @@ Step 2. The user changes the input in the command box. The `TextStateStorage#sav
* Pros: Reduces the number of writes to the storage file, reducing performance overhead.
* Cons: May not save the state of the command box in case of a crash.

### Relate feature
The `relate` command allows users to relate two persons via their unique `ID`. Exceptional behavior:
* If the `ID` provided by user does not exist, an error message is displayed.
* If the `ID` provided is not an integer value that is more than 0, an error message is displayed.

<puml src="diagrams/RelateActivityDiagram.puml" alt="RelateActivityDiagram" />

#### Current implementation
Given a command `relate i/1 i/2`, the `NetConnectParser` recognises the `relate` command and first instantiates a `RelateCommandParser` object. It then passes the command string into `RelateCommandParser#parse(...)`, where the input `i/1` and `i/2` is validated for its format. Following which, `RelateCommandParser` instantiates a `RelateCommand` object.

The`RelateCommand` object extends the `Command` interface, and hence contains a method called `execute(...)`, which takes in a `model`. A model can be thought of as a container for the application's data, and it also controls the exact contact list that the user will see. In the `execute(...)` command, we validate that NetConnect has both IDs `1` and `2` and, does not already have a relation. We add it to our RelatedList storage if both are true. To change our view and to ratify the successful command, we will have to change the view the user sees by instantiating a predicate called `IdContainsDigitsPredicate`. We will then pass it into the `model#stackFilters(predicate)` method in the `model` object to update the filtered list of persons to only include the two people with ID `1` and `2`.

Recalling that we also have a message box to inform the result of the actions taken (in prose form), the `RelateCommand#execute(...)` method will also return a `CommandResult` object, which contains the summary of the number of people listed.

#### Design considerations

**Aspect: How to store relations between contacts**

* **Alternative 1 (current choice)**: Store the Related List within the NetConnect model as a JSON file. Each time a relate command is done, we will just have to save the NetConnect model.
* Pros: This approach requires a single command for saving and loading and does not violate encapsulation of classes. Saving and loading does not have to be exposed to wider classes and done within the NetConnect model interface.
* Cons: JSON files can be difficult to amend and maintain.

* **Alternative 2 (previously implemented)**: Store the Related List as a .txt file.
* Pros: Easier to edit, maintain, and implement.
* Cons: Not secure, and save and load implementation is exposed outside the NetConnect model.

* **Alternative 3**: Store Relations as another field in every person. A relate command would add the opposing contact to both persons provided.
* Pros: Easy to understand as a user. Querying of contacts will also be fast as the relations are stored within the same contact.
* Cons: Unnecessary to user, and complicates UI. Also has a higher potential for bugs given that the entire contact list has to be searched and updated each time a relation is added and subsequently removed.

### ShowRelated feature
The `showrelated` command allows users to view all persons related to a specific person via their unique `ID`. Exceptional behavior:
* If there are multiple `ID` provided by user, an error message is displayed.
Expand All @@ -306,7 +336,7 @@ The `showrelated` command allows users to view all persons related to a specific
#### Current implementation
Given a command `showrelated i/1`, the `NetConnectParser` recognises the `showrelated` command and first instantiates a `ShowRelatedCommandParser` object. It then passes the command string into `ShowRelatedCommandParser#parse(...)`, where the input `i/1` is validated for its format. Following which, `ShowRelatedCommandParser` instantiates a `ShowRelatedCommand` object.

The`ShowRelatedCommand` object extends the `Command` interface, and hence contains a method called `execute(...)`, which takes in a `model`. A model can be thought of as a container for the application's data, and it also can control the exact contact list that the user will see. In the `execute(...)` command, we extract all the tuples that contain ID `1` and use it to instantiate a predicate called `IdContainsDigitsPredicate` which extracts all the `ID` of the related profiles (excluding itself of ID `1`). We will then require the `model#stackFilters(predicate)` method in the `model` object to update the filtered list of persons to only include persons related to the person with ID of `1`.
The`ShowRelatedCommand` object extends the `Command` interface, and hence contains a method called `execute(...)`, which takes in a `model`. A model can be thought of as a container for the application's data, and it also controls the exact contact list that the user will see. In the `execute(...)` command, we extract all the tuples that contain ID `1` and use it to instantiate a predicate called `IdContainsDigitsPredicate` which extracts all the `ID` of the related profiles (excluding itself of ID `1`). We will then pass it into the `model#stackFilters(predicate)` method in the `model` object to update the filtered list of persons to only include persons related to the person with ID of `1`.

Recalling that we also have a message box to inform the result of the actions taken (in prose form), the `ShowRelatedCommand#execute(...)` method will also return a `CommandResult` object, which contains the summary of the number of people listed.

Expand All @@ -322,6 +352,31 @@ Recalling that we also have a message box to inform the result of the actions ta
* Pros: Smaller chunk of data is extracted, reducing the amount of data to be processed as data is filtered out during read from storage.
* Cons: More complex implementation as the data is filtered out during read from storage, requiring filtering with String data instead of as IdTuple.

### Unrelate feature
The `unrelate` command allows users to unrelate two persons via their unique `ID`. Exceptional behavior:
* If the `ID` provided by user does not exist, an error message is displayed.
* If the `ID` provided is not an integer value that is more than 0, an error message is displayed.

<puml src="diagrams/UnrelateActivityDiagram.puml" alt="UnrelateActivityDiagram" />

#### Current implementation
Given a command `unrelate i/1 i/2`, the `NetConnectParser` recognises the `unrelate` command and first instantiates an `UnrelateCommandParser` object. It then passes the command string into `UnrelateCommandParser#parse(...)`, where the input `i/1` and `i/2` is validated for its format. Following which, `UnrelateCommandParser` instantiates an `UnrelateCommand` object.

The`UnrelateCommand` object extends the `Command` interface, and hence contains a method called `execute(...)`, which takes in a `model`. A model can be thought of as a container for the application's data, and it also controls the exact contact list that the user will see. In the `execute(...)` command, we validate that NetConnect has both IDs `1` and `2` and already has a relation. We remove it from our RelatedList stored in NetConnect if both are true. To change our view and to ratify the successful user command, we will have to change the view the user sees by instantiating a predicate called `IdContainsDigitsPredicate`. We will then pass it into the `model#stackFilters(predicate)` method in the `model` object to update the filtered list of persons to only show the two people who have just been unrelated with the ID `1` and `2`.

Recalling that we also have a message box to inform the result of the actions taken (in prose form), the `UnrelateCommand#execute(...)` method will also return a `CommandResult` object, which contains the id of the two people, in a 1relates2 format..

#### Design considerations

**Aspect: What kind of unrelation will be done using the two IDs**

* **Alternative 1 (current choice)**: The two IDs given will be used to remove that specific relation.
* Pros: This approach would allow the user the greatest flexibility in removing relations between contacts.
* Cons: User may think that it would delete all relations from each contact.

* **Alternative 2**: The two IDs given will be used to remove all relations for the two contacts.
* Pros: Can help with resetting of all relations for the contact quickly.
* Cons: Since the showrelated feature can show the user which relations for the contact already exists, manual and more precise unrelation has more value. This multi-field input for unrelate may confuse users based on the existing relate command usage.

### Delete feature

Expand Down
22 changes: 22 additions & 0 deletions docs/diagrams/RelateActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12


title Activity: Relate command
start
:User executes relate command;

if () then ([else])
:Display error message;
else ([two numeric IDs provided])
if () then ([else])
:Display error message;
else ([Both IDs exist])
:Relate both profiles to each other;
:Display both profiles that are related;
endif
endif
stop
@enduml
22 changes: 22 additions & 0 deletions docs/diagrams/UnrelateActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12


title Activity: Unrelate command
start
:User executes unrelate command;

if () then ([else])
:Display error message;
else ([two numeric IDs provided])
if () then ([else])
:Display error message;
else ([Both IDs exist])
:Unrelate both profiles to each other;
:Display both profiles that have been unrelated;
endif
endif
stop
@enduml
Loading