Skip to content
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

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open

[Cao Peng] iP #236

wants to merge 45 commits into from

Conversation

Cp-John
Copy link

@Cp-John Cp-John commented Jan 28, 2021

first pull request

Copy link

@LimJunxue LimJunxue left a 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;

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 {

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 {

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?

Copy link

@glatiuden glatiuden left a 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.*;

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?

Comment on lines +17 to +22
/**
* 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.
*/

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)");

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?


try {
switch (parsedCommand[0]) {
case "done", "delete":

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;

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?

Comment on lines +1 to +2
package duke;
import duke.exception.DukeException;

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?

Copy link

@DineshMagesvaran DineshMagesvaran left a 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.

Comment on lines +21 to +25
/**
* @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
*/

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(" ");

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.

Comment on lines +14 to +21
public Event(String title, boolean isDone, LocalDate date) {
super(title, isDone);
this.date = date;
}

public Event(String title, LocalDate time) {
this(title, false, time);
}

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants