-
Notifications
You must be signed in to change notification settings - Fork 228
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
[Cao Peng] iP #236
base: master
Are you sure you want to change the base?
[Cao Peng] iP #236
Conversation
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.
Commented on code quality guidelines. Generally simple code and methods as abstraction is used well.
private Task parseTask(String taskType, String taskStr) throws DukeException { | ||
String pattern; | ||
Pattern r; | ||
Matcher m; |
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.
A more meaningful naming suggestion: String input, Pattern pattern, Matcher matcher. I found this issue in the Storage class as well.
* @return The task list which is loaded from the file. | ||
* @throws DukeException Exception if there is error when loading from the file. | ||
*/ | ||
public ArrayList<Task> load() throws DukeException { |
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 this method name be loadTasksFromStorage to explain the method more intuitively?
* @return A duke.task.Task object which represents a task as the string. | ||
* @throws DukeException Exception if there is error when parsing the task string. | ||
*/ | ||
public Task parseTask(String str) throws DukeException { |
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 this method be private instead, because it is independent of the whole program and is only used by the load method from the same class as an encapsulation?
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.
LGTM, almost. Just a few comments and suggestions on the coding standard violations.
@@ -0,0 +1,101 @@ | |||
package duke; | |||
|
|||
import duke.command.*; |
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.
Java coding standards stated that the imported classes should always be listed explicitly. I understand why you have imported * from duke.command package, but to comply with the guideline, would it be better to import explicitly instead?
/** | ||
* Deletes a task specified by task id from the task list. | ||
* @param taskId The task id of the task which will be deleted. | ||
* @return The task which is deleted. | ||
* @throws DukeException Exception if there is error when deleting the task. | ||
*/ |
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.
Do note that there should be an empty line between the description and the parameters. I noticed the same issue in your other JavaDoc comments as well. Perhaps consider configuring your IDE to help with this styling?
public class DeadlineTest { | ||
@Test | ||
public void deadlineTest() { | ||
assertEquals(new Deadline("return book", LocalDate.parse("2019-10-15")).toString(), "[D][ ] return book (by: Oct 15 2019)"); |
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 line has exceeded the limit of 120 words. Would it be better to separate it into 2 lines instead?
src/main/java/duke/Parser.java
Outdated
|
||
try { | ||
switch (parsedCommand[0]) { | ||
case "done", "delete": |
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.
Do note that there should be no indentation for case clauses as to adhere to the Java coding standard. I noticed the same issue in the other classes as well. Perhaps consider configuring your IDE to help with this styling?
import java.util.ArrayList; | ||
|
||
public class FindCommand extends Command { | ||
String keyword; |
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.
Despite not really violating the coding standards as it only mentioned that variable shouldn't be public, but since other classes or sub-classes are not accessing the keyword
variable, would it be better to declare it as private?
package duke; | ||
import duke.exception.DukeException; |
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.
Not explicitly stated in the Java coding standard but would it be neater and consistent if there is a breakline between package and import?
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 code is generally well-written and follows coding standards.
/** | ||
* @param fullCommand the user command | ||
* @return a duke.command.Command object which encapsulates the information of a parsed user command | ||
* @throws DukeException exception when there is an parsing error | ||
*/ |
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 short summary of the method could be written as the first sentence for this method header.
} else if (fullCommand.equals("list")) { | ||
return new ListCommand(); | ||
} else { | ||
String[] parsedCommand = fullCommand.split(" "); |
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.
Plural form could be used for this String array to make the variable name sound more like a collection of string values.
public Event(String title, boolean isDone, LocalDate date) { | ||
super(title, isDone); | ||
this.date = date; | ||
} | ||
|
||
public Event(String title, LocalDate time) { | ||
this(title, false, time); | ||
} |
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 better if javadoc comments were included as there is more than one constructor?
Add an assertion
Change switch case statement format
first pull request