From 95c0cac08a95efb26c03cd980094a55638c0225a Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 13 Nov 2023 16:08:16 +0800 Subject: [PATCH] Update DG for sidebar implementation --- docs/DeveloperGuide.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 3eccef0352c..3f76ca1c6cd 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -187,7 +187,7 @@ Classes used by multiple components are in the `seedu.addressbook.commons` packa This section describes some noteworthy details on how certain features are implemented. -### Overview +### Overview of How Commands Work The basic idea of what happens when a user types a command: 1. The LogicManager executes method is called and takes in the user's input. @@ -423,26 +423,25 @@ is to restart the app at the current moment. ### Appointment Sidebar Feature -The appointment sidebar is facilitated by `ModelManager`. It extends `Model` and stores an additional -`SortedList` object that represents all existing appointments. +The appointment sidebar is facilitated by `ModelManager`. It extends `Model` and stores an additional `SortedList` object that represents all existing appointments. +The `setAppointmentList()` method checks against `filteredPersons` to look for updates regarding existing `Appointment` objects. The `setAppointmentList()` method is called whenever there is a command that can potentially change the data stored, to ensure that the state of the appointment sidebar is as updated as possible. -The `setAppointmentList()` method checks against `filteredPersons` to look for updates regarding existing -`Appointment` objects. The `getAppointmentList()` method is called once during the startup of the program by -`getAppointmentList()` in `LogicManager`, which is in turn called by `MainWindow`. It returns the -`sortedList` object within `modelManager`. +The `getAppointmentList()` method is called once during the startup of the program by `getAppointmentList()` in `LogicManager`, which is in turn called by `MainWindow`. It returns the `sortedList` object within `modelManager`. + +Do note that appointments are inherently sorted by their date and time, with the earliest appointment showing up at the top. #### Design Considerations: -**Aspect: Where to create SortedList** +**Aspect: Where to create** `SortedList` * **Alternative 1 (current choice):** Implement it within `modelManager` - * Pros: `SortedAppointments` object references `filteredPersons` which ensures that the appointment sidebar - corresponds with `persons` from `addressBook`. - * Cons: Errors with respect to `addressBook` will affect the appointment sidebar rendered. + - Pros: `SortedAppointments` object references `filteredPersons` which ensures that the appointment sidebar + corresponds with `persons` from `addressBook`. In this implementation, `persons` acts as the single source of truth which provides all information to `modelManager`. + - Cons: Errors with respect to `addressBook` will affect the appointment sidebar rendered. * **Alternative 2:** Implement it within `addressBook` - * Pros: `persons` and `appointmentList` are handled separately within `addressBook` and hence the appointment + - Pros: `persons` and `appointmentList` are handled separately within `addressBook` and hence the appointment sidebar is not dependent on `persons` in `addressBook` - * Cons: `filteredPersons` and `sortedAppointments` might not correspond since `sortedAppointments` is no longer + - Cons: `filteredPersons` and `sortedAppointments` might not correspond since `sortedAppointments` is no longer dependent on `filteredPersons`. --------------------------------------------------------------------------------------------------------------------