[Syed Muhammad Aljunied] Duke Increments#341
[Syed Muhammad Aljunied] Duke Increments#341muhammadaljunied wants to merge 56 commits intonus-cs2103-AY1920S1:masterfrom
Conversation
Add toolVersion block in to Gradle code sample to prevent errors.
Change file mode on `gradle` to be executable (nus-cs2103-AY1920S1#9)
Gradle defaults to an empty stdin which results in runtime exceptions when attempting to read from `System.in`. Let's add some sensible defaults for students who may still need to work with the standard input stream.
Add configuration for console applications
Added Gradle Support Added Checkstyle plugin Added Shadow plugin Added JUnitTest Dependency
This reverts commit 721456d.
Added Gradle Support Added Checkstyle plugin Added Shadow plugin Added JUnitTest Dependency
Added Echo Added Exit
Implemented "List all task" feature
This reverts commit 708252a.
Implemented "List all task" feature
Implemented pattern matching for commands and arguments with regex Abstracted out Commands to reduce excessive if-else for executing commands Specific commands print their relevant messages Added Mark as completed
Resolved Checkstyle Errors Added package seedu.duke.trackables ahead of level-4 requirements
Refactored task object for abstraction Refactored Command objects to reflect abstraction of task object.
Updated patterns for Regex Added Support for Event, Todo, Deadline Added Error Abstractions for Common errors (Invalid Command, Invalid Arguments) Duke specific exceptions are thrown with original cause (if available) to provide more useful stack trace. ** Forgot to commit Level 4, thus tagged as level 4 and 5)
TSAI-HSIAO-HAN
left a comment
There was a problem hiding this comment.
The overall Java style seems correct. Can break some lines to increase readability.
| @Override | ||
| public void execute(List<Task> tasks) { | ||
| tasks.add(deadline); | ||
| echo( |
There was a problem hiding this comment.
The indentation for wrapped lines in execute method should be 8 spaces.
There was a problem hiding this comment.
Line 20 should be together with Line 19.
| @Override | ||
| public void execute(List<Task> tasks) { | ||
| tasks.get(taskId).markAsDone(); | ||
| echo( |
There was a problem hiding this comment.
The indentation for wrapped lines in execute method should be 8 spaces.
There was a problem hiding this comment.
Line 19 should be together with Line 18.
| @Override | ||
| public void execute(List<Task> tasks) { | ||
| tasks.add(event); | ||
| echo(new String[] { |
There was a problem hiding this comment.
The indentation for wrapped lines in execute method should be 8 spaces.
There was a problem hiding this comment.
This is the indentation that CheckStyle approves.
Line 19 at level 8
Line 20-22 at level 12
Line 23 at level 8 (to close the String array instantiation)
ChrisKheng
left a comment
There was a problem hiding this comment.
Last note: In the DeleteCommand class, maybe you want to consider not to decrease the index of the task by 1? Cuz I think maybe in the future you may need to retrieve the index of the task from the command and hence it may cause confusion or bug when the index is different from the "surface" index (i.e. the id starts from 1 when displaying the tasks). You can decrease the index by 1 in the execute() method when trying to retrieve the task.
Overall, I think you could improve on the structure of the program by separating the logic of the program into more classes (Single Responsibility Principle). This can make it easier to manage the program's code, especially when the program scale becomes larger and larger. All the best and cheers!
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class Duke { |
There was a problem hiding this comment.
Regarding Duke class, maybe you want to separate the functionalities in it into more classes? Like Storage, Parser etc. I think there are too many functionalities in the Duke class and it doesn't really correspond to the Single Responsibility principle in SOLID. It may make the process of changing the program's code to fit new requirement harder as it may be quite hard to locate the right piece of code to change among the extensive lines of code.
Also, I think the purpose of Duke class should act like a body which links all its parts(Storage, Parser, TaskList) together and not doing too much of logic. This concept may help you to refactor your code.
| * Prints out the message. | ||
| * @param messages Array of messages to show. | ||
| */ | ||
| protected void echo(String[] messages) { |
There was a problem hiding this comment.
Maybe you want to separate the logic of printing, handling database into more classes such as Storage and Parser? This would reduce the responsibility of the Command classes and may aid in coding or making changes when doing further extensions of the program.
|
|
||
| @Override | ||
| public void execute(List<Task> tasks) { | ||
| tasks.get(taskId).markAsDone(); |
There was a problem hiding this comment.
Maybe you want to assign the task that you have retrieved to a variable so that later you can directly call toString() on it? This will then prevent from doing two get(), which means traversing twice through the list, which can increase the complexity of the solution.
|
|
||
| import java.util.List; | ||
|
|
||
| public class TodoCommand extends Command { |
There was a problem hiding this comment.
Maybe it's good to rename the TodoCommand, DeadlineCommand and EventCommand to maybe AddToDoCommand, AddDeadlineCommand and AddEventCommand? This can improve the clarity of the code.
| public class Task { | ||
| protected String description; | ||
| protected boolean isDone; | ||
|
|
There was a problem hiding this comment.
Maybe it would be good to make an enum to label the respective classes (ToDo, Deadline, Event)? This may help in the future when you want to extend your program.
|
|
||
| public class Event extends Task { | ||
|
|
||
| protected String at; |
There was a problem hiding this comment.
Maybe you want to use another name such as "time" instead of "at" for the string which stores the date? I think this would improve the clarity of your code.
|
|
||
| public class Deadline extends Task { | ||
|
|
||
| protected String by; |
There was a problem hiding this comment.
Maybe you want to use "deadline" instead of "by" to improve the clarity of the code?
Resolved Checkstyle Issues
Refactored Command Arguments parsing into respective command objects Error handling now cleaner with more specific error messages.
# Conflicts: # src/main/java/seedu/duke/Duke.java # src/main/java/seedu/duke/trackables/Deadline.java
…flict on Duke.java.
Abstracted out Ui and printing operations to Ui.java from Duke.java Updated Exceptions with new constructor e*(String message)
Updated Javadocs. Updated UI to handle reading inputs. Refactored IndexOutOfBounds error handling to TaskList from DeleteCommand and DoneCommand.
This reverts commit da3854e.
* branch-JavaDoc: Added Complete JavaDoc.
* branch-CodingStandard: Updated codebase to match Java Coding Standards. # Conflicts: # src/main/java/seedu/duke/commands/AddCommand.java # src/main/java/seedu/duke/trackables/Event.java
…e previous commit.
Linked UI with Duke.
Added missing Javadocs. Added UI tweaks
Added Stop handler when user closes using window close Added wrapping width for text node in UI
No description provided.