-
Notifications
You must be signed in to change notification settings - Fork 140
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
[CS2113-T10-2] BookBob #11
base: master
Are you sure you want to change the base?
[CS2113-T10-2] BookBob #11
Conversation
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class Main { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This main method is very long. Perhaps you could consider refactoring the code to separate the functionalities for parsing with a 'parser' package similar to what was done in the IP.
src/main/java/bookbob/Main.java
Outdated
case "add": | ||
logger.log(Level.INFO, "Processing add command"); | ||
try{ | ||
int nameStart = input.indexOf("n/"); | ||
int nricStart = input.indexOf("ic/"); | ||
int visitStart = input.indexOf("v/"); | ||
|
||
if (nameStart == -1) { | ||
System.out.println("Please provide the patient's name."); | ||
logger.log(Level.INFO, "Name of the patient is not provided"); | ||
break; | ||
} | ||
|
||
if (nricStart == -1) { | ||
System.out.println("Please provide the patient's NRIC."); | ||
logger.log(Level.INFO, "NRIC of the patient is not provided"); | ||
break; | ||
} | ||
|
||
String visitDateString = input.substring(visitStart + 2).trim(); | ||
try { | ||
// Attempt to parse using a standard formatter | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm"); | ||
LocalDateTime time = LocalDateTime.parse(visitDateString, formatter); | ||
} catch (DateTimeParseException e) { | ||
System.out.println("Invalid visit date format. Please use 'dd-MM-yyyy HH:mm' format."); | ||
logger.log(Level.INFO, "Invalid visit date format provided"); | ||
break; | ||
} | ||
|
||
commandHandler.add(input, records); | ||
logger.log(Level.INFO, "Successfully processed add command"); | ||
} catch (Exception e) { | ||
logger.log(Level.WARNING, "Error processing add command", e); | ||
System.out.println("Error in adding patient record, specific error: " + e.getMessage()); | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it could be a good idea to extract the logic in each individual switch cases as a method as some of these switch cases are pretty lengthy and extracting method would make the code more concise and readable. This applies to all switch cases in the main method.
List<Appointment> appointments = new ArrayList<>(); | ||
String[] inputs = input.split("/"); | ||
String details = inputs[1]; | ||
if (inputs[0].equals("n")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be a good idea to do
String filter = inputs[0];
and then use the filter variable to check the conditions for easier readability.
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class FileHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could use slightly different method names to name the different methods in this file. I was confused for a bit when I saw multiple pairs of methods with the exact same method name.
src/main/java/bookbob/Main.java
Outdated
|
||
while (true) { | ||
String input = in.nextLine(); | ||
String[] inputArr = input.split(" ", 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be a good idea to name the variable in full as Arr is not that commonly used to refer to Array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it up! 😺
@startuml | ||
'https://plantuml.com/sequence-diagram | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat and tidy, very detailed.
You may consider adding colours and hide the footbox 👍
docs/AfterAppointment.puml
Outdated
name = John Doe | ||
nric = S123A | ||
date = 18-11-2024 | ||
time = 18:00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can consider using "" for strings
docs/NewAppointment.puml
Outdated
Doctor -> Main ++ | ||
Main -> Record ** | ||
Main -> AppointmentRecord ** | ||
Main -> FileHandler ++ : initFile(records) | ||
FileHandler -> Main -- : | ||
Main -> FileHandler ++ : initFile(appointmentRecords) | ||
FileHandler -> Main -- : | ||
Main -> CommandHandler ** : | ||
Doctor -> Main : appointment("John Doe, S123A, 18-11-2024, 18:00") | ||
Main -> CommandHandler ++: commandHandler.appointment("John Doe, S123A, 18-11-2024, 18:00") | ||
CommandHandler -> AppointmentRecord ++ : appointmentRecord.checkAvailability("18-11-2024, 18:00") | ||
AppointmentRecord -> CommandHandler -- : nextAvailableTime | ||
group alt [nextAvailableTime == "18:00"] | ||
CommandHandler -> Appointment ** | ||
CommandHandler -> Appointment ++ : new Appointment("John Doe", "S123A", "18-11-2024", "18:00") | ||
Appointment -> CommandHandler -- : appointment | ||
|
||
CommandHandler -> AppointmentRecord ++ : appointmentRecords.addAppointment(appointment) | ||
AppointmentRecord -> CommandHandler -- | ||
else | ||
end | ||
CommandHandler -> FileHandler ++ : FileHandler.autosave(appointmentRecords) | ||
FileHandler -> CommandHandler -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may wish to consider deactivating the activation bar after the completion
@startuml | ||
'https://plantuml.com/sequence-diagram | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found many rounded rectangles instead of rectangles, from my knowledge, we have to use rectangles.
docs/NewAppointment.puml
Outdated
Doctor -> Main : appointment("John Doe, S123A, 18-11-2024, 18:00") | ||
Main -> CommandHandler ++: commandHandler.appointment("John Doe, S123A, 18-11-2024, 18:00") | ||
CommandHandler -> AppointmentRecord ++ : appointmentRecord.checkAvailability("18-11-2024, 18:00") | ||
AppointmentRecord -> CommandHandler -- : nextAvailableTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for any return arrows, it should be -->
instead
docs/AfterAppointment.puml
Outdated
Main --> Record | ||
Main --> AppointmentRecord | ||
Main --> FileHandler | ||
Main --> CommandHandler | ||
Main --> Scanner | ||
CommandHandler --> FileHandler | ||
CommandHandler --> AppointmentRecord | ||
CommandHandler --> Record | ||
AppointmentRecord --> Appointment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object diagram well drawn, can consider adding labels to make it clearer
docs/NewAppointment.puml
Outdated
Doctor -> Main ++ | ||
Main -> Record ** | ||
Main -> AppointmentRecord ** | ||
Main -> FileHandler ++ : initFile(records) | ||
FileHandler -> Main -- : | ||
Main -> FileHandler ++ : initFile(appointmentRecords) | ||
FileHandler -> Main -- : | ||
Main -> CommandHandler ** : | ||
Doctor -> Main : appointment("John Doe, S123A, 18-11-2024, 18:00") | ||
Main -> CommandHandler ++: commandHandler.appointment("John Doe, S123A, 18-11-2024, 18:00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing colon in front of the entity name (i.e.":Main" instead of "Main" )
docs/DeveloperGuide.md
Outdated
| Action | Format | Example | | ||
|---|---|---| | ||
| Help | `help` | `help` | | ||
| Add | `add n/NAME ic/NRIC [p/PHONE_NUMBER] [d/DIAGNOSIS] [m/MEDICATION] [ha/HOME_ADDRESS] [dob/DATE_OF_BIRTH] [v/VISIT_DATE_TIME] [al/ALLERGY] [s/SEX] [mh/MEDICALHISTORY]` | `add n/James Ho ic/S9534567A p/91234567 d/Asthma m/Albuterol ha/NUS-PGPR dob/01011990 v/21-10-2024 15:48 al/Pollen s/Female mh/Diabetes` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the appointment command syntax, should the date format dd-mm-yyyy and time format HH:mm be clarified further in the command summary?
1. Adding visits | ||
1. (Positive) Test Case: `addVisit ic/S9876543A v/21-10-2024 15:48 d/Fever,Cough m/Paracetamol,Cough Syrup` <br> | ||
Expected: Visit added to patient's record with diagnoses and medications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would providing a few additional examples for variations help reduce input errors?
docs/DeveloperGuide.md
Outdated
### Data Persistence (Saving and Loading) | ||
|
||
1. Automatic Storage | ||
1. Test case: Add/edit/delete records, then restart application | ||
- Expected: All changes are preserved after restart | ||
- Note: Data is automatically saved to `bookbob_data.txt` in the `data` folder (same directory as Bookbob.jar) | ||
|
||
2. File Management | ||
1. Test case: Manually View saved data | ||
- Action: Navigate to `data` folder (same directory as BookBob.jar) and open `bookbob_data.txt` | ||
- Note: Do not manually modify the file contents to prevent data corruption. Saving and loading data is automated as long as file is not corrupted. | ||
|
||
## Instructions for manual testing | ||
2. Test case: Delete data file and restart application | ||
- Action: Delete `bookbob_data.txt` from the `data` folder | ||
- Expected: New `bookbob_data.txt` file is automatically generated. The missing text file will not result in any error as files will be generated automatically. | ||
- Note: This can be used to start with a fresh database if needed | ||
|
||
{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing} | ||
3. Error Handling | ||
1. Test case: Corrupt the data file manually, then start application | ||
- Expected: Error message is shown about invalid data | ||
- Note: BookBob will continue to function | ||
- Recovery options: | ||
* Option 1: Manually remove corrupted lines from `bookbob_data.txt` | ||
* Option 2: Delete `bookbob_data.txt` to start afresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to expand on recovery options when the data file is corrupted? Should we add specific steps or a short troubleshooting guide to assist users in recovering from data corruption errors?
docs/DeveloperGuide.md
Outdated
The Sequence Diagram for the execution of the appointment feature: | ||
![img.png](NewAppointmentSD.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be helpful to label key interactions between objects (e.g., CommandHandler, AppointmentRecord, FileHandler) to clarify their roles?
![img.png](AfterExecutionOD.png) | ||
|
||
The Sequence Diagram for the execution of the appointment feature: | ||
![img.png](NewAppointmentSD.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the arrows of creating object point to its activation bar?
|
||
Object Diagram after execution of appointment feature: | ||
![img.png](AfterExecutionOD.png) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be clearer if a class diagram is included.
|
||
The Sequence Diagram for the execution of the appointment feature: | ||
![img.png](NewAppointmentSD.png) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the return arrow in dash line?
|
||
Object Diagram after execution of appointment feature: | ||
![img.png](AfterExecutionOD.png) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the object diagram before execution of application feature and after execution of application feature the same?
docs/DeveloperGuide.md
Outdated
{Describe the target user profile} | ||
Dr Bob is a General Practitioner running his own private clinic. | ||
He manages everything independently, attending to numerous patients with diverse health concerns each day. | ||
The demanding workload and long hours often leave him exhausted and sleep-deprived. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a bit too much detail about background?
docs/AfterExecutionOD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the before and after execution diagram supposed to be exactly the same?
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the record object have a constructor?
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for Appointment record
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appointment should also have a constructor
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the return arrows be dotted
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the activation bar for Main and CommandHandler are not closed
docs/NewAppointmentSD.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommandHandler should call autoSave in FileHandler after getting the return nextAvailableTime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, the diagrams follow the confection with no major violations, good job. However, there seems to be too much detail in the DeveloperGuide.md as well as on the diagrams themselves.
docs/AddVisitSequenceDiagram.puml
Outdated
":Main" -> ":Scanner"**: new Scanner() | ||
activate ":Scanner" | ||
":Main" <-- ":Scanner": in:Scanner | ||
deactivate ":Scanner" | ||
|
||
":Main" -> ":Records"**: new Records() | ||
activate ":Records" | ||
":Main" <-- ":Records": records:Records | ||
deactivate ":Records" | ||
|
||
":Main" -> ":AppointmentRecord"**: new AppointmentRecord() | ||
activate ":AppointmentRecord" | ||
":Main" <-- ":AppointmentRecord": appointmentRecord:AppointmentRecord | ||
deactivate ":AppointmentRecord" | ||
|
||
participant ":FileHandler" as FileHandler <<class>> | ||
":Main" -> FileHandler ++: initFile(records) | ||
return | ||
|
||
":Main" -> FileHandler ++: initFile(appointmentRecord) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be an overlap with the MainSequenceDiagram.puml. Moving this part to a separate diagram and just referencing it would improve readability, would you agree?
docs/CommandHandler.puml
Outdated
+help(): void | ||
+add(input: String, records: Records): void | ||
+list(records: Records): void | ||
+edit(input: String, records: Records): void | ||
+editVisit(input: String, records: Records): void | ||
+delete(nric: String, records: Records): void | ||
+find(input: String, records: Records): void | ||
+exit(input: String): void | ||
+addVisit(input: String, records: Records): void | ||
+Appointment(input: String, appointmentRecord: AppointmentRecord): void | ||
+deleteAppointment(input: String, appointmentRecord: AppointmentRecord): void | ||
+listAppointment(appointmentRecord: AppointmentRecord): void | ||
+findAppointment(input: String, appointmentRecord: AppointmentRecord): void | ||
+deleteAppointment(appointmentRecord: AppointmentRecord): void | ||
-findNextFieldStart(input: String, currentIndex: int): int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that it is clear which component is responsible for what. Wouldn't all of these methods be a bit overwhelming for a reader? Isn't it too detailed?
docs/Main.puml
Outdated
@startuml | ||
'https://plantuml.com/class-diagram | ||
|
||
class Main { | ||
-{static} logger: Logger {readOnly} | ||
+{static} main(args: String[]): void | ||
} | ||
|
||
class Patient {} | ||
class Visit {} | ||
class Main {} | ||
class Records {} | ||
class CommandHandler {} | ||
class AppointmentRecord {} | ||
|
||
|
||
CommandHandler --> Appointment : searches and modifies > | ||
AppointmentRecord "1" o-- "many" Appointment | ||
Main --> CommandHandler : calls > | ||
Main --> FindVisit : calls > | ||
CommandHandler --> Patient : searches and modifies > | ||
FindVisit --> Visit : searches > | ||
Records "1" o-- "many" Patient | ||
Patient "1" o-- "many" Visit | ||
@enduml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this diagram is provided, important for understanding other ones.
> The Object Diagram before the execution of "add" command: | ||
![img.png](ObjectDiagramBeforeAddPatient.png) | ||
|
||
> The Object Diagram after the execution of "add" command: | ||
![img.png](ObjectDiagramAfterAddPatient.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not blatantly clear what is being changed, too much detail. Maybe it would be beneficial to put the diagrams side by side?
add author
fix author
…l optional parameters (denoted by square brackets)
…leasingV2.0 Do a final check before releasing v2.0
Fix bugs in the commands
Fix minor typo in Main.java
* 'master' of https://github.com/AY2425S1-CS2113-T10-2/tp: (58 commits) Fix minor typo in Main.java Fixed typo Fix typo issue Fix bugs in the commands Make the error message printed out for find command consistent for all optional parameters (denoted by square brackets) Change the help output to guide the users correctly fix author add author add author update_DG fix CI Main Class Test Create RecordsTest class with JUnit tests to ensure 100% test coverage (class, method, line, branch) Update author tags Delete BookBobTest.java from v1.0 (we shifted all test methods into CommandHandlerTest.java) Create a PatientTest class and add JUnit tests to achieve 100% test coverage (class, method, line and branch) Update AboutUs.md Update AboutUs.md Update princecatt.md Update AboutUs.md ... # Conflicts: # docs/AboutUs.md
Update Main class diagram and fix typo in Jz PPP
"patient record management" header in DG reduce size
…ations about mandatory fields and optional fields
…nly "F", "Female", "M" or "Male" (case-insensitive) are allowed as inputs for sex
…leasingv2.1 Final check before releasing v2.1
Fix minor formatting issues in UG
update JZ PPP
update JZ PPP
Update PPP
update JZ PPP
Update PPP for Cora Zhang
fix Typos in UG
update JZ PPP
BookBob helps General Practitioner Doctors to manage patient details. It is optimised for CLI users, so that they are able to access
information of the patients faster by searching their specific details such as Name or NRIC.