Skip to content

Commit

Permalink
Merge pull request #168 from NgChunMan/166-Update-DG
Browse files Browse the repository at this point in the history
166 Update DG
  • Loading branch information
NgChunMan authored Oct 28, 2023
2 parents 83645ae + 7550f69 commit c31cfe3
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 48 deletions.
29 changes: 10 additions & 19 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,45 +97,36 @@ The `UI` component,

### Logic component

**API
** : [`Logic.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/logic/Logic.java)
**API** : [`Logic.java`](https://github.com/AY2324S1-CS2103T-W15-2/tp/tree/master/src/main/java/seedu/address/logic/Logic.java)

Here's a (partial) class diagram of the `Logic` component:

<puml src="diagrams/LogicClassDiagram.puml" width="550"/>

The sequence diagram below illustrates the interactions within the `Logic` component, taking `execute("delete 1")` API
call as an example.
The sequence diagram below illustrates the interactions within the `Logic` component, taking `execute("rmt 1")` API call as an example.
`rmt` is the command word for DeleteTaskCommand class. By executing the command `rmt 1`, tha task with index number 1 will be deleted.

<puml src="diagrams/DeleteSequenceDiagram.puml" alt="Interactions Inside the Logic Component for the `delete 1` Command" />
<puml src="diagrams/DeleteTaskSequenceDiagram.puml" alt="Interactions Inside the Logic Component for the `rmt 1` Command" />

<box type="info" seamless>

**Note:** The lifeline for `DeleteCommandParser` should end at the destroy marker (X) but due to a limitation of
PlantUML, the lifeline reaches the end of diagram.
**Note:** The lifeline for `DeleteTaskCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.
</box>

How the `Logic` component works:

1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates
a parser that matches the command (e.g., `DeleteCommandParser`) and uses it to parse the command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which
is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed (e.g. to delete a person).
1. When `Logic` is called upon to execute a command, it is passed to an `ProfBookParser` object which in turn creates a parser that matches the command (e.g., `DeleteTaskCommandParser`) and uses it to parse the command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteTaskCommand`) which is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed (e.g. to delete a task).
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

Here are the other classes in `Logic` (omitted from the class diagram above) that are used for parsing a user command:

<puml src="diagrams/ParserClasses.puml" width="600"/>

How the parsing works:

* When called upon to parse a user command, the `AddressBookParser` class creates an `XYZCommandParser` (`XYZ` is a
placeholder for the specific command name e.g., `AddCommandParser`) which uses the other classes shown above to parse
the user command and create a `XYZCommand` object (e.g., `AddCommand`) which the `AddressBookParser` returns back as
a `Command` object.
* All `XYZCommandParser` classes (e.g., `AddCommandParser`, `DeleteCommandParser`, ...) inherit from the `Parser`
interface so that they can be treated similarly where possible e.g, during testing.
* When called upon to parse a user command, the `ProfBookParser` class creates an `XYZCommandParser` (`XYZ` is a placeholder for the specific command name e.g., `Mark`) which uses the other classes shown above to parse the user command and create a `XYZCommand` object (e.g., `MarkCommand`) which the `ProfBookParser` returns back as a `Command` object.
* All `XYZCommandParser` classes (e.g., `EditCommandParser`, `HelpCommandParser`, ...) inherit from the `Parser` interface so that they can be treated similarly where possible e.g, during testing.

### Model component

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

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":ProfBookParser" as ProfBookParser LOGIC_COLOR
participant ":DeleteTaskCommandParser" as DeleteTaskCommandParser LOGIC_COLOR
participant "d:DeleteTaskCommand" as DeleteTaskCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManagerStatic MODEL_COLOR
participant "opr:TaskOperation" as TaskOperation MODEL_COLOR
end box

[-> LogicManager : execute("rmt 1")
activate LogicManager

LogicManager -> ProfBookParser : parseCommand("rmt 1")
activate ProfBookParser

create DeleteTaskCommandParser
ProfBookParser -> DeleteTaskCommandParser
activate DeleteTaskCommandParser

DeleteTaskCommandParser --> ProfBookParser
deactivate DeleteTaskCommandParser

ProfBookParser -> DeleteTaskCommandParser : parse("1")
activate DeleteTaskCommandParser

create DeleteTaskCommand
DeleteTaskCommandParser -> DeleteTaskCommand
activate DeleteTaskCommand

DeleteTaskCommand --> DeleteTaskCommandParser : d
deactivate DeleteTaskCommand

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

ProfBookParser --> LogicManager : d
deactivate ProfBookParser

LogicManager -> DeleteTaskCommand : execute(state)
activate DeleteTaskCommand

DeleteTaskCommand -> ModelManagerStatic : taskOperation(new Path("~/grp-001"))
activate ModelManagerStatic

create TaskOperation
ModelManagerStatic -> TaskOperation
activate TaskOperation

TaskOperation --> ModelManagerStatic : opr
deactivate TaskOperation

ModelManagerStatic --> DeleteTaskCommand :opr
deactivate ModelManagerStatic

DeleteTaskCommand -> TaskOperation : opr.deleteTask(1)
activate TaskOperation

TaskOperation --> DeleteTaskCommand

destroy TaskOperation

DeleteTaskCommand -> ModelManagerStatic : updateList()
activate ModelManagerStatic

ModelManagerStatic --> DeleteTaskCommand
deactivate ModelManagerStatic

create CommandResult
DeleteTaskCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteTaskCommand : result
deactivate CommandResult

DeleteTaskCommand --> LogicManager : result
deactivate DeleteTaskCommand

[<--LogicManager
deactivate LogicManager
@enduml
8 changes: 4 additions & 4 deletions docs/diagrams/LogicClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ skinparam classBackgroundColor LOGIC_COLOR

package Logic as LogicPackage {

Class AddressBookParser
Class ProfBookParser
Class XYZCommand
Class CommandResult
Class "{abstract}\nCommand" as Command
Expand All @@ -27,8 +27,8 @@ Class HiddenOutside #FFFFFF
HiddenOutside ..> Logic

LogicManager .right.|> Logic
LogicManager -right->"1" AddressBookParser
AddressBookParser ..> XYZCommand : creates >
LogicManager -right->"1" ProfBookParser
ProfBookParser ..> XYZCommand : creates >

XYZCommand -up-|> Command
LogicManager .left.> Command : executes >
Expand All @@ -38,7 +38,7 @@ LogicManager --> Storage
Storage --[hidden] Model
Command .[hidden]up.> Storage
Command .right.> Model
note right of XYZCommand: XYZCommand = AddCommand, \nFindCommand, etc
note right of XYZCommand: XYZCommand = EditCommand, \nMarkCommand, etc

Logic ..> CommandResult
LogicManager .down.> CommandResult
Expand Down
6 changes: 3 additions & 3 deletions docs/diagrams/ParserClasses.puml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ XYZCommandParser ..> ArgumentMultimap
XYZCommandParser ..> ArgumentTokenizer
ArgumentTokenizer .left.> ArgumentMultimap
XYZCommandParser ..> CliSyntax
CliSyntax ..> Prefix
CliSyntax ..> Option
XYZCommandParser ..> ParserUtil
ParserUtil .down.> Prefix
ArgumentTokenizer .down.> Prefix
ParserUtil .down.> Option
ArgumentTokenizer .down.> Option
XYZCommand -up-|> Command
@enduml
22 changes: 0 additions & 22 deletions docs/diagrams/tracing/LogicSequenceDiagram.puml

This file was deleted.

0 comments on commit c31cfe3

Please sign in to comment.