Skip to content

[Yan Lyn] iP#469

Open
yanlynnnnn wants to merge 47 commits into
nus-cs2103-AY2021S1:masterfrom
yanlynnnnn:master
Open

[Yan Lyn] iP#469
yanlynnnnn wants to merge 47 commits into
nus-cs2103-AY2021S1:masterfrom
yanlynnnnn:master

Conversation

@yanlynnnnn

Copy link
Copy Markdown

No description provided.

damithc and others added 30 commits July 23, 2020 23:27
This reverts commit 652a853.
# Conflicts:
#	src/main/java/Duke.java
* 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 hogantan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread src/main/java/Duke.java

private static Storage storage;
private TaskList inputs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the name "inputs" be a little more precise when it comes to referring a TaskList?

Comment thread src/main/java/Duke.java
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think adding a JavaDoc description here would allow other users to better understand what exactly Duke does?

Comment thread src/main/java/Duke.java Outdated


/*
* Constructs Duke Object, constructs UI, storage and TaskList object to initialize

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing full stop for JavaDoc here!

Comment thread src/main/java/Duke.java
}

// Input class represents user inputted tasks
public static class Input implements Serializable {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting use of static classes and interfaces here!

Comment thread src/main/java/Duke.java Outdated

// Input class represents user inputted tasks
public static class Input implements Serializable {
boolean done;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could try naming this boolean more like a boolean, something like isDone.

Comment thread src/main/java/Duke.java
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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread src/main/java/Duke.java
int len = inputs.size();
for(int i = 0; i < len; i++) {
Input input = inputs.get(i);
if (input.content.contains(keyword)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the code more readable if you use extra method to handle the conditions? 🤔

Comment thread src/main/java/Duke.java Outdated

//Parser class deals with making sense of user command
public static class Parser {
String nextLine;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these missing their access modifiers? It would be best to make them private!

Comment thread src/main/java/Duke.java Outdated
inputs.taskEvent(nextLine);
} else if (nextLine.startsWith("find")) {
inputs.taskFind(nextLine);
} else if (nextLine.equals("list")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could try making these code more succint by nesting lesser conditionals together!

Comment thread src/main/java/Duke.java Outdated
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could try using the tick symbol instead of a '/'. The four-digit hex code for the tick symbol is \u2713.

@tanwayne890 tanwayne890 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits to fix for more readability.

Comment thread src/main/java/Duke.java Outdated
* @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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main/java/Duke.java
}
}

public static void main (String[]args) throws DukeException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any spacing errors?

Comment thread src/main/java/Duke.java
String content;
String id;
LocalDate time;
String printTime;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to understand a variable or method if you use noun for variable/class and verb for methods/functions?
🤔

Comment thread src/main/java/Duke.java
this.id = "[E]";
this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. 👍

Comment thread src/main/java/Duke.java Outdated
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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the readability improve if you break the line before operator? 🤔

Comment thread src/main/java/Duke.java
int len = inputs.size();
for(int i = 0; i < len; i++) {
Input input = inputs.get(i);
if (input.content.contains(keyword)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the code more readable if you use extra method to handle the conditions? 🤔

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.

3 participants