Skip to content

Commit

Permalink
Merge branch 'master' into DG-additions
Browse files Browse the repository at this point in the history
  • Loading branch information
cookiedan42 committed Nov 8, 2021
2 parents b6d023a + f635922 commit 0b4deb7
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
72 changes: 72 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ title: Developer Guide
* [Help feature](#help-feature)
* [Birthday Reminder feature](#birthday-reminder-feature)
* [Mailing List feature](#mailing-list-feature)
* [Command History feature](#command-history-feature)
* [Command Assistant feature](#command-assistant-feature)

* [Documentation, logging, testing, configuration, dev-ops](#documentation-logging-testing-configuration-dev-ops)
* [Appendix: Requirements](#appendix-requirements)
Expand Down Expand Up @@ -388,6 +390,8 @@ Step 4. The user decides to view the usage of `add` to learn to add a contact, a

Step 5. CONNECTIONS will display a detailed help message on the usage of the `add` command in `ResultDisplay`.

![HelpSequenceDiagram](images/HelpCommandDiagram.png)


### Birthday Reminder feature

Expand Down Expand Up @@ -469,6 +473,74 @@ Step 10. The headers and rows are written to the CSV file that is specified by t
* Cons: Additional calls to logic and model are needed to get the required information.


### Command History feature

#### Implementation

The operation is exposed in `CommandBox` and `CommandHistory`.

The user keystroke will be read in `CommandBox#handleKeyStroke`, which will call the appropriate method in `CommandHistory` to retrieve the previous and next commands. The retrieved commands are passed into `CommandBox#commandTextField` to be displayed.

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

Step 1. The user launches the application for the first time. All contacts are displayed by default.

Step 2. The user executes `find n/David t/friend t/football` to search for a matching contact.

Step 3. User wants to retrieve previous command and presses the `UP` key.

Step 4. `CommandBox#handleKeyStroke` reads the `UP` keystroke and calls `CommandHistory#getPreviousCommand`.

Step 5. `CommandHistory` retrieves the previous command and returns it.

Step 6. `CommandBox` displays the previous command in the Command Box.

![CommandHistoryActivityDiagram](images/CommandHistoryActivityDiagram.png)

#### Design considerations:

**Aspect: Implementation of Command History:**

* **Option 1 (current choice):** Generate `CommandHistory` as a Singleton class.
* Pros: Ensures that there is only one set of history that is tracked.
* Cons: Complicates testing as different versions of history cannot be created.

* **Option 2:** Generate `CommandHistory` as a normal class.
* Pros: Makes testing easier as multiple `CommandHistory` objects can be created with different history to test different conditions.
* Cons: Possible conflicting history if `CommandHistory` is not updated properly.

### Command Assistant feature

#### Implementation

The operation is exposed in `SystemCommand`, specifically in `SystemCommand#execute`.

The user keystroke will be read in `CommandBox#handleKeyStroke`. The user input will be evaluated by `SystemCommand#execute` to determine the appropriate help message to display.

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

Step 1. The user launches the application for the first time. All contacts are displayed by default.

Step 2. The user enters `find ` to search for a matching contact.

Step 3. `CommandBox#handleKeyStroke` reads `find ` input string and calls `SystemCommand#execute`.

Step 4. `SystemCommand` evaluates the user input and returns the appropriate help message.

Step 5. CONNECTIONS will display a help message in `ResultDisplay`.

#### Design considerations:

**Aspect: Implementation of Command Assistant:**

* **Option 1:** Create a `AssistantCommand` class which extends from `Command` to handle the features of `Command Assistant`.
* Pros: Simplifies implementation as only an additional subclass needs to be created.
* Cons: Creates an additional command that users may be able to utilise, which they are not supposed to.

* **Option 2 (current choice):** Create a new type of command called `SystemCommand` that does not extend from `Command`.
* Pros: Prevents potential issues such as users using an additional command which they are not supposed to use.
* Cons: Requires additional code to interface with `Logic`, 'MainWindow` and `CommandBox`.

### [Proposed] Partial data recovery feature
Allows the user to recover partial data if the data file becomes corrupted.

Expand Down
36 changes: 36 additions & 0 deletions docs/diagrams/CommandHistoryActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@startuml
'https://plantuml.com/activity-diagram-beta

start
:UI receives keystroke;
switch()
case ([keystroke `UP`])
:Attempts to retrieves previous command;
if () then ([has command history])
if () then ([has previous command])
:Displays previous command;
else ([no previous command])
:Displays last command in history;
endif
else ([no command history])
:Displays nothing;
endif
case ([keystroke `DOWN`])
:Attempts to retrieves next command;
if () then ([has command history])
if () then ([has next command])
:Displays next command;
else ([no next command])
:Displays nothing;
endif
else ([no command history])
:Displays nothing;
endif
case ([other keystrokes])
:Retrieves Command Assistant;
endswitch


stop

@enduml
69 changes: 69 additions & 0 deletions docs/diagrams/HelpCommandDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@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 ":HelpCommandParser" as HelpCommandParser LOGIC_COLOR
participant "h:HelpCommand" as HelpCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

UI -> LogicManager : execute("help add")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("help add")
activate AddressBookParser

create HelpCommandParser
AddressBookParser -> HelpCommandParser
activate HelpCommandParser

HelpCommandParser --> AddressBookParser
deactivate HelpCommandParser

AddressBookParser -> HelpCommandParser : parse("add")
activate HelpCommandParser

create HelpCommand
HelpCommandParser -> HelpCommand
activate HelpCommand

HelpCommand --> HelpCommandParser : h
deactivate HelpCommand

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

AddressBookParser --> LogicManager : h
deactivate AddressBookParser

LogicManager -> HelpCommand : execute()
activate HelpCommand

create CommandResult
HelpCommand -> CommandResult
activate CommandResult
CommandResult -> HelpCommand
deactivate CommandResult


HelpCommand --> LogicManager : result
deactivate HelpCommand

UI <--LogicManager: result
deactivate LogicManager
'Hidden arrow to position the destroy marker below the end of the activation bar.
HelpCommand -[hidden]-> LogicManager
destroy HelpCommand



@enduml
Binary file added docs/images/CommandHistoryActivityDiagram.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/HelpCommandDiagram.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 0b4deb7

Please sign in to comment.