Skip to content

Commit

Permalink
Update sort activity diagram and reoragnise implementation in develop…
Browse files Browse the repository at this point in the history
…er guide
  • Loading branch information
whitesnowx committed Apr 13, 2024
1 parent 420b03c commit 552779a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 68 deletions.
107 changes: 50 additions & 57 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ This is to prevent `FilterCommand` from taking on more responsibilities (Separat
`FilterCommand` having `setPersonPredicate()` method:
This is so that `FilterCommand` has the required argument of type `Predicate<Person>` to be used in the `updateFilteredPersonList()` method. Since the `Predicate<Person>` object is created by chaining the multiple predicates, no parsing is involved to create this `Predicate`.

### Sort Feature
### Sort feature

##### Implementation
##### How the feature is implemented

The sort mechanism is facilitated by JavaFX's `SortedList` within ModelManager, `SortCommand` and `SortCommandParser`. `SortCommandParser` extends the types of command parsers in StaffBookParser, and returns a `SortCommand` to be executed by the LogicManager. This execution also updates the `SortedList` in Model via ModelManager. Additionally, it implements the following operations:

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

<img src="images/SortActivityDiagram.png" width="450" />

#### Design considerations:
#### What designs were considered:
**Aspect: Determining order of sorting of an attribute:**

* **Current Design:** Get order of sorting from user, prompting for an input in the form of toCompare.
Expand Down Expand Up @@ -320,6 +320,53 @@ Below are some explanations for the special considerations in the implementation
`FindCommmandParser` parsing the `Predicate` objects:
This is to prevent `FindCommand` from taking on more responsibilities (Separation of Concerns).

### Meeting feature

Meeting is feature that allows the user to keep track of any events they may have with the particular contact. It contains the description of the meeting event with the date and time it would occur.

#### How the feature is implemented

Meeting contains two attributes ```MeetingDescription``` and ```MeetingDateTime``` class. ```MeetingDescription```
is used to handle any valid description of the meeting with only alphanumeric values, while the ```MeetingDateTime```
is used to handle any valid date time values. Each of this meeting are stored in a list data class ```MeetingList``` that
contains each of the meetings related to each other stored in an ```ObservableList```. The ``` MeetingManager ``` is
used to manage any operations that require viewing or sorting of meetings from the ```MeetingList``` class.

#### What designs were considered:

**Aspect: How the meetings are stored :**

* **Alternative 1 (current choice):** Store meetings in an ObservableList.
* Pros: Better segregation of the OOP functionalities, and good integration with the UI ListView.
* Cons: Larger code complexity.

* **Alternative 2:** Store meetings in a Set.
* Pros: Easier implementation.
* Cons: There is an efficiency gap as each element has to be placed into a list before it can be shown to the UI ListView.

### Fav/unfav feature

The feature enables us to sets/remove a particular contact using an index as favourite.

#### How the feature is implemented

The Fav/Unfav feature is implemented via the `FavCommand` and `UnfavCommand`, which is supported by the `FavCommandParser` and `UnfavCommandParser` respectively.
The `FavCommandParser` and `UnfavCommandParser` implements the `Parser` interface.

1. `LogicManager` receives the user input which is parsed by the `StaffConnectParser`.
2. After splitting the user input into `commandWord` and `arguments` based on the regex pattern of the user input, the `StaffConnectParser` invokes the `FavCommandParser`/`UnfavCommandParser` based on the `commandWord`, calling the method `parse` with `arguments` as the method arguments
3. `FavCommandParser`/`UnfavCommandParser` takes in the `args` string and parse it into with the static `ParserUtil#parseIndex(args)` function. If the `INDEX` format is invalid, a `ParseException` will be thrown.
4. `FavCommandParser`/`UnfavCommandParser` then creates the `FavCommand`/`UnfavCommand` and returns it.
5. The `LogicManager` executes the `FavCommand`/`UnfavCommand`, which creates a `Person` with the `Favourite` attribute set as `true`/`false` respectively and updates the model with this new `Person`.

The following sequence diagram shows how the `fav` command works:

![Fav Command Sequence Diagram](images/FavSequenceDiagram.png)

Similarly, how the `unfav` command works is shown below:

![Unfav Command Sequence Diagram](images/UnfavSequenceDiagram.png)

### \[Proposed\] Undo/redo feature

#### Proposed Implementation
Expand Down Expand Up @@ -402,60 +449,6 @@ The following activity diagram summarizes what happens when a user executes a ne
* 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.

_{more aspects and alternatives to be added}_

### \[Proposed\] Data archiving

_{Explain here how the data archiving feature will be implemented}_


### Meeting

Meeting is feature that allows the user to keep track of any events they may have with the particular contact. It contains the description of the meeting event with the date and time it would occur.

#### Implementation

Meeting contains two attributes ```MeetingDescription``` and ```MeetingDateTime``` class. ```MeetingDescription```
is used to handle any valid description of the meeting with only alphanumeric values, while the ```MeetingDateTime```
is used to handle any valid date time values. Each of this meeting are stored in a list data class ```MeetingList``` that
contains each of the meetings related to each other stored in an ```ObservableList```. The ``` MeetingManager ``` is
used to manage any operations that require viewing or sorting of meetings from the ```MeetingList``` class.

#### Design considerations:

**Aspect: How the meetings are stored :**

* **Alternative 1 (current choice):** Store meetings in an ObservableList.
* Pros: Better segregation of the OOP functionalities, and good integration with the UI ListView.
* Cons: Larger code complexity.

* **Alternative 2:** Store meetings in a Set.
* Pros: Easier implementation.
* Cons: There is an efficiency gap as each element has to be placed into a list before it can be shown to the UI ListView.

### Fav/unfav feature

The feature enables us to sets/remove a particular contact using an index as favourite.

#### Implementation

The Fav/Unfav feature is implemented via the `FavCommand` and `UnfavCommand`, which is supported by the `FavCommandParser` and `UnfavCommandParser` respectively.
The `FavCommandParser` and `UnfavCommandParser` implements the `Parser` interface.

1. `LogicManager` receives the user input which is parsed by the `StaffConnectParser`.
2. After splitting the user input into `commandWord` and `arguments` based on the regex pattern of the user input, the `StaffConnectParser` invokes the `FavCommandParser`/`UnfavCommandParser` based on the `commandWord`, calling the method `parse` with `arguments` as the method arguments
3. `FavCommandParser`/`UnfavCommandParser` takes in the `args` string and parse it into with the static `ParserUtil#parseIndex(args)` function. If the `INDEX` format is invalid, a `ParseException` will be thrown.
4. `FavCommandParser`/`UnfavCommandParser` then creates the `FavCommand`/`UnfavCommand` and returns it.
5. The `LogicManager` executes the `FavCommand`/`UnfavCommand`, which creates a `Person` with the `Favourite` attribute set as `true`/`false` respectively and updates the model with this new `Person`.

The following sequence diagram shows how the `fav` command works:

![Fav Command Sequence Diagram](images/FavSequenceDiagram.png)

Similarly, how the `unfav` command works is shown below:

![Unfav Command Sequence Diagram](images/UnfavSequenceDiagram.png)

--------------------------------------------------------------------------------------------------------------------

## **Documentation, logging, testing, configuration, dev-ops**
Expand Down
25 changes: 14 additions & 11 deletions docs/diagrams/SortActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ start
:User enters a sort command;


if() then ([attributes are not sortable])
:get person from list;
while (have person to compare)
while(attribute value with the next person in the list are equal or no more attributes)
:use next attribute to check;
endwhile
if() then ([person smaller])
:shift front;
else([person bigger])
:shift back;
if() then ([attributes are sortable])
if () then ([list is not empty])
repeat
:get next person in list
and adds to sorted list;
:compare with persons in sorted list;
if () then ([person smaller])
:shift up;
else ([person bigger])
:shift down;
endif
endwhile
repeat while () is ([have next person to sort]) not ([no more person to sort])

else ([list is empty])
endif
:Shows sorted person list;
else([any attribute is not sortable])
:displays Sort Usage message;
Expand Down
Binary file modified docs/images/SortActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 552779a

Please sign in to comment.