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

Update developer guide for sort feature #69

Merged
merged 7 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
78 changes: 49 additions & 29 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: page
title: Developer Guide
---
* Table of Contents
{:toc}
{:toc}

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

Expand Down Expand Up @@ -154,6 +154,28 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa

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

### Sort feature

#### About

The sort feature is an inbuilt element of `SalesPunch` where it allows the sales person to sort the address book according to a certain attribute.

#### Implementation

The sort mechanism is facilitated by `SortCommandParser` where it parses sort commands, triggering and associating the given attribute to a `SortCommand` class which extends `Command`. When `SortCommand` gets executed, `ModelManager#sortPersonList()` sorts the address book according to the given attribute.

<div markdown="span" class="alert alert-info">:information_source: **Note:** If the given input is not a valid attribute of a `Person` class, it will throw an error indicating invalid attribute.

</div>

The following sequence diagram shows how the sort operation works:

![SortSequenceDiagram](images/SortSequenceDiagram.png)

The following activity diagram summarizes what happens when a user executes a sort command:

![SortActivityDiagram](images/SortActivityDiagram.png)

### Lead Status feature

The Lead Status feature aims to provide information about the contact based on when the status was last set.
Expand All @@ -174,8 +196,6 @@ one, the command returns and does not alter the previous lead status (and timest
![](images/StatusSequenceDiagram.png)
(to update seq diagram to reflect timestamp implementation)



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

#### Proposed Implementation
Expand Down Expand Up @@ -246,13 +266,13 @@ 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.
* Pros: Easy to implement.
* Cons: May have performance issues in terms of memory usage.
* 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.
* 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}_

Expand Down Expand Up @@ -349,10 +369,10 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
**Extensions**

* 1a. AddressBook detects an error in the entered data.
* 1a1. AddressBook requests for the correct data.
* 1a2. User enters new data.
* Steps 1a1-1a2 are repeated until the data entered is correct.
* Use case resumes from step 2.
* 1a1. AddressBook requests for the correct data.
* 1a2. User enters new data.
* Steps 1a1-1a2 are repeated until the data entered is correct.
* Use case resumes from step 2.

Use case ends.

Expand All @@ -374,10 +394,10 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
Use case ends.

* 3a. AddressBook detects an error in the entered data.
* 3a1. AddressBook requests for the correct data.
* 3a2. User enters new data.
* Steps 3a1-3a2 are repeated until the data entered is correct.
* Use case resumes from step 4.
* 3a1. AddressBook requests for the correct data.
* 3a2. User enters new data.
* Steps 3a1-3a2 are repeated until the data entered is correct.
* Use case resumes from step 4.

Use case ends.

Expand All @@ -387,7 +407,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

1. User requests to list persons
2. AddressBook shows a list of persons
3. User requests to delete a specific person in the list
3. User requests to delete a specific person in the list
4. AddressBook displays a confirmation message
5. User confirms to delete the specific person in the list
6. AddressBook deletes the person
Expand All @@ -414,7 +434,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
2. Should be able to hold up to 1000 clients without a noticeable sluggishness in performance for typical usage.
3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.
4. A user should be able to work with 20 tasks per client without having noticeable sluggishness in performance for typical usage.
5. If a user wishes to use the email templating feature, a default mail app on their system is required.
5. If a user wishes to use the email templating feature, a default mail app on their system is required.

### Glossary

Expand All @@ -438,15 +458,15 @@ testers are expected to do more *exploratory* testing.

1. Initial launch

1. Download the jar file and copy into an empty folder
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 contacts. The window size may not be optimum.

1. Saving window preferences

1. Resize the window to an optimum size. Move the window to a different location. Close the window.
1. Resize the window to an optimum size. Move the window to a different location. Close the window.

1. Re-launch the app by double-clicking the jar file.<br>
1. Re-launch the app by double-clicking the jar file.<br>
Expected: The most recent window size and location is retained.

1. _{ more test cases …​ }_
Expand All @@ -455,23 +475,23 @@ testers are expected to do more *exploratory* testing.

1. Deleting a person while all persons are being shown

1. Prerequisites: List all persons using the `list` command. Multiple persons in the list.
1. Prerequisites: List all persons using the `list` command. Multiple persons 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.
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.

1. Test case: `delete 0`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.
1. Test case: `delete 0`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.

1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.
1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.

1. _{ more test cases …​ }_

### Saving data

1. Dealing with missing/corrupted data files

1. _{explain how to simulate a missing/corrupted file, and the expected behavior}_
1. _{explain how to simulate a missing/corrupted file, and the expected behavior}_

1. _{ more test cases …​ }_
7 changes: 7 additions & 0 deletions docs/diagrams/SortActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@startuml
start
:User executes sort command;
:Sort AddressBook by attribute;
:Save AddressBook to addressBookStateList;
stop
@enduml
62 changes: 62 additions & 0 deletions docs/diagrams/SortSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@startuml
!include style.puml

Actor User as user USER_COLOR
Participant ":UI" as ui UI_COLOR
Participant ":LogicManager" as LM LOGIC_MANAGER_COLOR
Participant ":AddressBookParser" as ABP ADDRESS_BOOK_PARSER_COLOR
Participant ":SortCommandParser" as SCP SORT_COMMAND_PARSER_COLOR
Participant ":SortCommand" as SC SORT_COMMAND_COLOR
Participant "model:ModelManager" as MM MODEL_MANAGER_COLOR
Participant ":Storage" as storage STORAGE_COLOR

user -[USER_COLOR]> ui : "sort name"
activate ui UI_COLOR

ui -[UI_COLOR]> LM : execute("sort name")
activate LM LOGIC_MANAGER_COLOR

LM -[LOGIC_MANAGER_COLOR]> ABP : parseCommand("sort name")
activate ABP ADDRESS_BOOK_PARSER_COLOR

ABP -[ADDRESS_BOOK_PARSER_COLOR]> SCP : parse("name")
activate SCP SORT_COMMAND_PARSER_COLOR

create SC
SCP -[SORT_COMMAND_PARSER_COLOR]> SC : SortCommand("name")
activate SC SORT_COMMAND_COLOR

SC -[SORT_COMMAND_COLOR]-> SCP
deactivate SC

SCP -[SORT_COMMAND_PARSER_COLOR]-> ABP
deactivate SCP

ABP --[ADDRESS_BOOK_PARSER_COLOR]> LM : command
deactivate ABP

LM -[LOGIC_MANAGER_COLOR]> SC : execute(model)
activate SC SORT_COMMAND_COLOR

SC -[SORT_COMMAND_COLOR]> MM : sortPersonList("name")
activate MM MODEL_MANAGER_COLOR
deactivate MM

SC --[SORT_COMMAND_COLOR]> LM : commandResult
deactivate SC

LM -[LOGIC_MANAGER_COLOR]> storage : saveAddressBook(addressBook)
activate storage STORAGE_COLOR
storage -[STORAGE_COLOR]> storage : Save to file
activate storage STORAGE_COLOR_T1
storage --[STORAGE_COLOR]> storage
deactivate storage
storage --[STORAGE_COLOR]> LM
deactivate storage

LM --[LOGIC_MANAGER_COLOR]> ui
deactivate LM

ui--[UI_COLOR]> user
deactivate ui
@enduml
30 changes: 30 additions & 0 deletions docs/diagrams/style.puml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,36 @@
!define STORAGE_COLOR_T3 #806600
!define STORAGE_COLOR_T2 #544400

!define LOGIC_MANAGER_COLOR #8093F1
!define LOGIC_MANAGER_COLOR_T1 #5A72ED
!define LOGIC_MANAGER_COLOR_T2 #3553E9
!define LOGIC_MANAGER_COLOR_T3 #1839DC
!define LOGIC_MANAGER_COLOR_T2 #1430B8

!define ADDRESS_BOOK_PARSER_COLOR #78E0DC
!define ADDRESS_BOOK_PARSER_COLOR_T1 #59D9D5
!define ADDRESS_BOOK_PARSER_COLOR_T2 #37D2CD
!define ADDRESS_BOOK_PARSER_COLOR_T3 #2AB7B2
!define ADDRESS_BOOK_PARSER_COLOR_T2 #229692

!define SORT_COMMAND_PARSER_COLOR #31CB00
!define SORT_COMMAND_PARSER_COLOR_T1 #119822
!define SORT_COMMAND_PARSER_COLOR_T2 #2A7221
!define SORT_COMMAND_PARSER_COLOR_T3 #1E441E
!define SORT_COMMAND_PARSER_COLOR_T2 #152614

!define SORT_COMMAND_COLOR #F29469
!define SORT_COMMAND_COLOR_T1 #EF7A43
!define SORT_COMMAND_COLOR_T2 #EB5F1E
!define SORT_COMMAND_COLOR_T3 #CE4E12
!define SORT_COMMAND_COLOR_T2 #A9400F

!define MODEL_MANAGER_COLOR #D496A7
!define MODEL_MANAGER_COLOR_T1 #CA7D91
!define MODEL_MANAGER_COLOR_T2 #BE6079
!define MODEL_MANAGER_COLOR_T3 #AE4762
!define MODEL_MANAGER_COLOR_T2 #913B52

!define USER_COLOR #000000

skinparam BackgroundColor #FFFFFFF
Expand Down
Binary file added 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.
Binary file added docs/images/SortSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.