Skip to content

Commit

Permalink
Merge pull request #90 from yucheng11122017/pin-command
Browse files Browse the repository at this point in the history
Update developer guide for pin command
  • Loading branch information
yucheng11122017 authored Oct 22, 2021
2 parents 127cf7b + a9d2205 commit c5807bc
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,39 @@ _{more aspects and alternatives to be added}_

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

### \[Work in progress\] Pin feature

#### Proposed Implementation

The operation are exposed in the `Command` interface as `Command#Execute`, specifically in `PinCommand#Execute`

Given below is an example usage scenario and how the pin mechanism behaves at each step.

Step 1. The user launches the application for the first time.

Step 2. The user executes `add n/David …​` to add a new person.

Step 3. Connections displays the new person.

Step 4. The user decides that the contact, currently at index 1, is important and should be pinned. User executes pin 1

Step 5. Connections will pin the contact and moves the contact to the top of the list of contacts.

The following sequence diagram shows how the pin operation works:

![PinSequenceDiagram](images/PinSequenceDiagram.png)

#### Design considerations:

**Aspect: How pin executes:**

* **Alternative 1:** Person has a boolean field isPinned to indicate if the person is pinned or not
* Pros: Easy to implement, less memory usage
* Cons: Less flexibility in expanding the usage of pin.

* **Alternative 2 (current choice):** Person has Pin object to indicate if the person is pinned or not
* Pros: More flexible to expand, other methods can be added to Pin if needed.
* Cons: Will use more memory.

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

Expand Down
82 changes: 82 additions & 0 deletions docs/diagrams/PinSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@startuml
!include style.puml

box UI UI_COLOR
participant "UI" as UI UI_COLOR
end box

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":PinCommandParser" as PinCommandParser LOGIC_COLOR
participant "d:PinCommand" as PinCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

UI -> LogicManager : execute("pin 1")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("pin 1")
activate AddressBookParser

create PinCommandParser
AddressBookParser -> PinCommandParser
activate PinCommandParser

PinCommandParser --> AddressBookParser
deactivate PinCommandParser

AddressBookParser -> PinCommandParser : parse("1")
activate PinCommandParser

create PinCommand
PinCommandParser -> PinCommand
activate PinCommand

PinCommand --> PinCommandParser : d
deactivate PinCommand

PinCommandParser --> AddressBookParser : d
deactivate PinCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
PinCommandParser -[hidden]-> AddressBookParser
destroy PinCommandParser

AddressBookParser --> LogicManager : d
deactivate AddressBookParser

LogicManager -> PinCommand : execute()
activate PinCommand

PinCommand -> Model : getFilteredPersonList()
activate Model
Model --> PinCommand : filteredPersonList
deactivate Model

PinCommand -> PinCommand : createPinnedPerson(personToPin)
activate PinCommand
PinCommand --> PinCommand : pinnedPerson
deactivate PinCommand

create CommandResult
PinCommand -> CommandResult
activate CommandResult

CommandResult --> PinCommand
deactivate CommandResult

PinCommand -> Model : setPerson(originalPerson, pinnedPerson)
activate Model
Model --> PinCommand
deactivate Model

PinCommand --> LogicManager : result
deactivate PinCommand

UI <--LogicManager: result
deactivate LogicManager
@enduml
Binary file added docs/images/PinSequenceDiagram.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 c5807bc

Please sign in to comment.