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

docs: Add FindFreeTimeSequenceDiagram to DG #160

Merged
merged 2 commits into from
Apr 15, 2024
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
31 changes: 30 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,40 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa

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

### Finding free time between friends based on allocated module timings

Finding free time between students is done through `find_free_time d/Wed st/1200 et/1400`.

`LogicManager` first calls `AddressBookParser` which then runs `parse_command` and then calls
`FindFreeTimeCommandParser` which then parses the arguments, validates them, and then creates
a new `FindFreeTimeCommand` instance. The arguments passed in is then used within a newly `IsFreePredicate`
instance within the `FindFreeTimeCommand` instance, and the `LogicManager` then executes it.

This then calls the existing `updateFilteredStudentList`with the `IsFreePredicate` within the `Model` instance.

The following is the sequence diagram for this example.

<img src="diagrams/FindFreeTimeSequenceDiagram.png" />

#### Design Considerations

Well, it was rather straightforward to implement this design because it has extreme similarities to the `FindCommand`
that already existed within the AB3. Only tough parts were the filtering of conditions to ensure the
time range stated doesn't overlap with the module timings of the students within the list.

* **Alternative 1 (current choice):** Re-use code from `FindCommand` sequence.
* Pros: Easy to implement.
* Cons: Had to reconfigure the code to match our usecase.

In short, this was the straightforward options with no backlash as it was a insanely easy command to create
considering that existing groundwork has been laid. No issues has been faced with the implementation of the design
other than rough hiccups (i.e allowing end time to be earlier than start time)

### Adding a ModuleTiming to a Student

Adding a class to a student in ModContacts is done by the command `add_timing i/1 m/CS2103T d/Mon st/0800 et/1200`

The entry point for this command is when the `LogicManager` parses the command, gets a `AddStudentModuleCommand`,
The entry point for this command is when the `LogicManager` parses the command, gets a `AddStudentModuleCommand`,
and then executes it.

`AddStudentModuleCommand` performs some validations, then adds the `ModuleTiming` to the designated
Expand Down
Binary file added docs/diagrams/FindFreeTimeSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions docs/diagrams/FindFreeTimeSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@startuml
'Belongs to @taufiq, Copied from author of AddModuleTimingSequenceDiagram
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":FindFreeTimeCommandParser" as FindFreeTimeCommandParser LOGIC_COLOR
participant "d:FindFreeTimeCommand" as FindFreeTimeCommand 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("find_free_time d/Wed st/1200 et/1400")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("find_free_time d/Wed st/1200 et/1400")
activate AddressBookParser

create FindFreeTimeCommandParser
AddressBookParser -> FindFreeTimeCommandParser
activate FindFreeTimeCommandParser

FindFreeTimeCommandParser --> AddressBookParser
deactivate FindFreeTimeCommandParser

AddressBookParser -> FindFreeTimeCommandParser : parse("d/Wed st/1200 et/1400")
activate FindFreeTimeCommandParser

create FindFreeTimeCommand
FindFreeTimeCommandParser -> FindFreeTimeCommand
activate FindFreeTimeCommand

FindFreeTimeCommand --> FindFreeTimeCommandParser :
deactivate FindFreeTimeCommand

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

AddressBookParser --> LogicManager : d
deactivate AddressBookParser

LogicManager -> FindFreeTimeCommand : execute(m)
activate FindFreeTimeCommand

FindFreeTimeCommand -> Model : updateFilteredStudentList(freePredicate)
activate Model

Model --> FindFreeTimeCommand
deactivate Model

create CommandResult
FindFreeTimeCommand -> CommandResult
activate CommandResult

CommandResult --> FindFreeTimeCommand
deactivate CommandResult

FindFreeTimeCommand --> LogicManager : r
deactivate FindFreeTimeCommand

[<--LogicManager
deactivate LogicManager
@enduml
Loading