[Yan Lyn] iP#469
Conversation
This reverts commit 652a853.
This reverts commit 2c4ba83.
This reverts commit 6f3abf9.
# Conflicts: # src/main/java/Duke.java
* branch-Level-8: Level 8
* branch-Level-7: no message Level 8 Level 7 # Conflicts: # listStore.ser # src/main/java/Duke.java
This reverts commit 49a8bb8.
* branch-A-CodingStandard: A-CodingStandard # Conflicts: # src/main/java/Duke.java
* branch-Level-9: Level-9 # Conflicts: # src/main/java/Duke.java
* commit 'a75fceeb74708da6ac524c08ef526d38e60ee56b': build.gradle: Update version to 8.29 Add Gradle support
hogantan
left a comment
There was a problem hiding this comment.
Overall pretty good!
However one important thing to note is that, I realized that all classes were nested inside the Duke class which could get clunky and messy as the project gets bigger. You should try to distribute and package each class separately to make it neater. Also, I realized that most if not all the classes are static as well which should be removed they are redundant to the class.
For the JavaDocs, just do not forget about the fullstops!
|
|
||
| private static Storage storage; | ||
| private TaskList inputs; |
There was a problem hiding this comment.
Could the name "inputs" be a little more precise when it comes to referring a TaskList?
| import java.time.format.DateTimeFormatter; | ||
| import java.time.temporal.ChronoUnit; | ||
|
|
||
|
|
There was a problem hiding this comment.
Do you think adding a JavaDoc description here would allow other users to better understand what exactly Duke does?
|
|
||
|
|
||
| /* | ||
| * Constructs Duke Object, constructs UI, storage and TaskList object to initialize |
| } | ||
|
|
||
| // Input class represents user inputted tasks | ||
| public static class Input implements Serializable { |
There was a problem hiding this comment.
Interesting use of static classes and interfaces here!
|
|
||
| // Input class represents user inputted tasks | ||
| public static class Input implements Serializable { | ||
| boolean done; |
There was a problem hiding this comment.
You could try naming this boolean more like a boolean, something like isDone.
| if (nextLine.equals("todo") || nextLine.equals("todo ")) { | ||
| throw new DukeException("OOPS!!! The description of a todo cannot be empty."); | ||
| } | ||
| Todo todo = new Todo(nextLine.substring(5)); |
There was a problem hiding this comment.
I realised the use of substring to get specific keywords from the user input. An alternative to this would be to use the split() function of String to split the user input up!
| int len = inputs.size(); | ||
| for(int i = 0; i < len; i++) { | ||
| Input input = inputs.get(i); | ||
| if (input.content.contains(keyword)) { |
There was a problem hiding this comment.
Maybe you can consider making this more succint. In other words, try to avoid nesting conditionals which could get quite messy, though I am guilty of this too!
There was a problem hiding this comment.
Would the code more readable if you use extra method to handle the conditions? 🤔
|
|
||
| //Parser class deals with making sense of user command | ||
| public static class Parser { | ||
| String nextLine; |
There was a problem hiding this comment.
Are these missing their access modifiers? It would be best to make them private!
| inputs.taskEvent(nextLine); | ||
| } else if (nextLine.startsWith("find")) { | ||
| inputs.taskFind(nextLine); | ||
| } else if (nextLine.equals("list")) { |
There was a problem hiding this comment.
You could try making these code more succint by nesting lesser conditionals together!
| System.out.println("Noted. I've removed this task:"); | ||
| Input inputType = inputs.get(numTaskDone - 1); | ||
| if (inputType.done) { | ||
| System.out.println(" " + inputType.id + "[/] " + inputType.content + inputType.printTime); |
There was a problem hiding this comment.
You could try using the tick symbol instead of a '/'. The four-digit hex code for the tick symbol is \u2713.
tanwayne890
left a comment
There was a problem hiding this comment.
Just some nits to fix for more readability.
| * @param nextLine, represents user input | ||
| * @throws DukeException if user does not specify which task done, or if task specified is not in list | ||
| */ | ||
| void taskDone(String nextLine) throws DukeException { |
There was a problem hiding this comment.
I notice you are trying to mark a task as done. Would it be better if you rename your method to verb? For example, markTaskDone.
| } | ||
| } | ||
|
|
||
| public static void main (String[]args) throws DukeException { |
| String content; | ||
| String id; | ||
| LocalDate time; | ||
| String printTime; |
There was a problem hiding this comment.
Is it better to understand a variable or method if you use noun for variable/class and verb for methods/functions?
🤔
| this.id = "[E]"; | ||
| this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")"; | ||
| } | ||
| } |
There was a problem hiding this comment.
I am glad that all of your code is maintained below the line length limit which is below 120 char, so the code view is better. 👍
| inputs.add(deadline); | ||
| int count = inputs.size(); | ||
| System.out.println("Got it. I've added this task: \n" + " [D][x] " + deadline.content + | ||
| deadline.printTime + "\n Now you have " + count + " tasks in the list"); |
There was a problem hiding this comment.
Would the readability improve if you break the line before operator? 🤔
| int len = inputs.size(); | ||
| for(int i = 0; i < len; i++) { | ||
| Input input = inputs.get(i); | ||
| if (input.content.contains(keyword)) { |
There was a problem hiding this comment.
Would the code more readable if you use extra method to handle the conditions? 🤔
This reverts commit 311532c.
* branch-A-CodeQuality: A-CodeQuality
No description provided.