Skip to content

Commit

Permalink
Merge pull request #176 from nusliuyifan/Update_DG
Browse files Browse the repository at this point in the history
Update DG Storage Part and some other parts related to Event
  • Loading branch information
nusliuyifan authored Apr 12, 2024
2 parents e6fe871 + 5b15f2f commit 16bc0ee
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
14 changes: 10 additions & 4 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The bulk of the app's work is done by the following four components:

**How the architecture components interact with each other**

The *Sequence Diagram* below shows how the components interact with each other for the scenario where the user issues the command `delete 1`.
The *Sequence Diagram* below shows how the components interact with each other for the scenario where the user issues the command `addp n/David p/98987676 e/[email protected] a/NUS t/student`.

<puml src="diagrams/ArchitectureSequenceDiagram.puml" width="574" />

Expand Down Expand Up @@ -80,7 +80,7 @@ The `UI` component,
* executes user commands using the `Logic` component.
* listens for changes to `Model` data so that the UI can be updated with the modified data.
* keeps a reference to the `Logic` component, because the `UI` relies on the `Logic` to execute commands.
* depends on some classes in the `Model` component, as it displays `Person` object residing in the `Model`.
* depends on some classes in the `Model` component, as it displays `Person` `Event` objects residing in the `Model`.

### Logic component

Expand All @@ -90,6 +90,7 @@ 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("delp 1")` API call as an example.

<puml src="diagrams/DeleteParticipantSequenceDiagram.puml" alt="Interactions Inside the Logic Component for the `delete 1` Command" />
Expand All @@ -98,13 +99,16 @@ The sequence diagram below illustrates the interactions within the `Logic` compo

**Note:** The lifeline for `DeletePersonCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline continues till 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., `DeletePersonCommandParser`) and uses it to parse the command.
2. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeletePersonCommand`) which is executed by the `LogicManager`.
3. The command can communicate with the `Model` when it is executed (e.g. to delete a person).<br>

Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the `Model`) to achieve.
4. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

Expand All @@ -125,7 +129,9 @@ How the parsing works:
The `Model` component,

* stores the address book data i.e., all `Person` objects (which are contained in a `UniquePersonList` object).
* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores the event book data i.e., all `Event` objects (which are contained in a `UniquePersonList` object)
* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ person list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores the currently 'selected' `Event` object (e.g., results of a select query) as a separate _filtered_ event list which is exposed to outsiders as an unmodifiable `ObservableList<Event>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
* does not depend on any of the other three components (as the `Model` represents data entities of the domain, they should make sense on their own without depending on other components)

Expand All @@ -145,7 +151,7 @@ The `Model` component,
<puml src="diagrams/StorageClassDiagram.puml" width="550" />

The `Storage` component,
* can save global participant list data, event list data, participant list data of all added events in JSON format, and read it back into corresponding objects.
* can save global participant list data, event list data, and participant list data of all added events in JSON format, and read it back into corresponding objects.
* inherits from`AddressBookStorage` `EventBook Storage` and `UserPrefStorage`, which means it can be treated as either one (if only the functionality of only one is needed).
* depends on some classes in the `Model` component (because the `Storage` component's job is to save/retrieve objects that belong to the `Model`)

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

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":AddCommandParser" as AddCommandParser LOGIC_COLOR
participant "d:AddCommand" as AddCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

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

[-> LogicManager : execute("addp n/David...")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("addp n/David...")")
activate AddressBookParser

create AddCommandParser
AddressBookParser -> AddCommandParser
activate AddCommandParser

AddCommandParser --> AddressBookParser
deactivate AddCommandParser

AddressBookParser -> AddCommandParser : parse("n/David...")
activate AddCommandParser

create AddCommand
AddCommandParser -> AddCommand
activate AddCommand

AddCommand --> AddCommandParser :
deactivate AddCommand

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

AddressBookParser --> LogicManager : d
deactivate AddressBookParser

LogicManager -> AddCommand : execute(m)
activate AddCommand

AddCommand -> Model : addPerson(n/David...)
activate Model

Model --> AddCommand
deactivate Model

create CommandResult
AddCommand -> CommandResult
activate CommandResult

CommandResult --> AddCommand
deactivate CommandResult

AddCommand --> LogicManager : r
deactivate AddCommand

[<--LogicManager
deactivate LogicManager
@enduml
6 changes: 3 additions & 3 deletions docs/diagrams/ArchitectureSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Participant ":Logic" as logic LOGIC_COLOR
Participant ":Model" as model MODEL_COLOR
Participant ":Storage" as storage STORAGE_COLOR

user -[USER_COLOR]> ui : "delete 1"
user -[USER_COLOR]> ui : "addp n/David p/98987676 e/[email protected] a/NUS t/student"
activate ui UI_COLOR

ui -[UI_COLOR]> logic : execute("delete 1")
ui -[UI_COLOR]> logic : execute("addp n/David p/98987676 e/[email protected] a/NUS t/student")
activate logic LOGIC_COLOR

logic -[LOGIC_COLOR]> model : deletePerson(p)
logic -[LOGIC_COLOR]> model : addPerson(p)
activate model MODEL_COLOR

model -[MODEL_COLOR]-> logic
Expand Down

0 comments on commit 16bc0ee

Please sign in to comment.