Skip to content

[hongyijie06] iP#179

Open
hongyijie06 wants to merge 33 commits into
nus-cs2113-AY2324S2:masterfrom
hongyijie06:master
Open

[hongyijie06] iP#179
hongyijie06 wants to merge 33 commits into
nus-cs2113-AY2324S2:masterfrom
hongyijie06:master

Conversation

@hongyijie06

Copy link
Copy Markdown

No description provided.

@mihirheda02 mihirheda02 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, I think the code is very easy to understand and read. I think just focus on cleaning up the code a bit 👌

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



while (!line.equals("bye")){

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 tried to look through the coding standard to see if there should be a space. There wasn't anything that specifically mentioned it, but all the examples had a space. It might be worth making this change throughout your code to keep it consistent.

Comment thread src/main/java/Duke.java

if (line.equals("list")){
for (int i = 0; i < index; i ++) {

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 think you can clean up random newlines like this

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

System.out.println((i + 1) + ". " + list[i]);
}
}else {

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 think adding a space between the "}" and "else" will follow coding standard more and keep the style of your code more consistent

Comment thread src/main/java/Duke.java Outdated
System.out.println("Hello! I'm apple");
System.out.println("What can I do for you?");

int index = 0;

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 think there should be one more space here for a 4 tab space

Comment thread src/main/java/Duke.java Outdated
Comment on lines +35 to +38




Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Additionally, I think you can clean up these new lines

Comment thread src/main/java/Duke.java Outdated
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String list[] = new String[100];

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 it would be more beneficial to have a more descriptive name like "tasks"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That might be better! Thank you!

@a-wild-chocolate a-wild-chocolate 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.

Good job! You follows the code rule and the code quality is high. Keep well in the following levels.

Comment thread src/main/java/Duke.java Outdated
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
Task[] list = new Task[100];

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 can try to use Arraylist which is more convenient in java

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

}
System.out.println("Bye. Hope to see you again soon!");

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 can try to use more methods e.g. sayBey() to make the program more extendable for the future levels.

@nichyjt nichyjt 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.

Hi Yi Jie,

I think this is good work. There are various ways we can further stretch your code to adhere to better code quality principles, and I hope you consider them!

  1. Throughout your program, there is heavy use of magic literals. This is not permissible by the course's coding quality metrics.
  2. Some of your variable names could be named better (especially those single letter ones)
  3. There is an opportunity to improve the code structure. Consider logically grouping your code by functionality and putting them into folders, rather than putting them into one file.
  4. There is an opportunity to improve the level of abstraction in your program. Some functionality is repetitive and could be abstracted out in a function, which can help you make your codebase smaller and neater!

Try and work on my comments before the next tutorial!

Also for your consideration: There is a way to autoformat your code automatically every time you Ctrl-S on intellij which will save you much pain. :)

Comment thread src/main/java/CreateFile.java Outdated
Comment on lines +6 to +21
File f = new File("TaskList.txt");
if (!f.exists()) {
try {
if (f.createNewFile()) {
System.out.println("File created: " + f.getAbsolutePath());
} else {
System.out.println("File creation failed.");
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
} else {
System.out.println("File already exists: " + f.getAbsolutePath());
}
}

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 use more descriptive names for your exceptions and files.
Avoid using magic values (the strings) as well!

Comment thread src/main/java/Deadline.java Outdated
@@ -0,0 +1,13 @@
public class Deadline extends Task{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formatting error here!

Comment thread src/main/java/EmptyLineException.java Outdated
Comment on lines +1 to +2
public class EmptyLineException extends Exception{
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formatting error for Exception{. Also, I'm not sure why your exception class is empty?

Comment thread src/main/java/Duke.java Outdated
public static void main(String[] args) throws UnexpectedCommandException, EmptyLineException, IOException {
ArrayList<Task> tasks = new ArrayList<Task>();

//greeting

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your comment could be more descriptive!

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

public static void main(String[] args) throws UnexpectedCommandException, EmptyLineException, IOException {

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 refactor out your magic string values!

Comment thread src/main/java/Event.java
Comment on lines +8 to +9
}
@Override

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 can consider adding a newline between line 8 & 9 to avoid making it look too squashed!

Comment thread src/main/java/ManageInputs.java Outdated
Comment on lines +23 to +32
while (s.hasNext()) {
String sLine = s.nextLine();
if (sLine.contains("[E]")) {
dealWithEvent(tasks, index, sLine);
} else if (sLine.contains("[D]")) {
dealWithDeadline(tasks, index, sLine);
} else if (sLine.contains("[T]")) {
dealWithTodo(tasks, index, sLine);
}
index++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a good application of SLAP! But perhaps the variable sLine could be renamed to make it clearer what this means?

Comment thread src/main/java/ManageInputs.java Outdated
Comment on lines +115 to +119
private void handleUnexpectedCommand(boolean isValidCommand) throws UnexpectedCommandException {
if (!isValidCommand) {
throw new UnexpectedCommandException();
}
}

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'm not sure what this abstraction is supposed to do. Is this necessary? If a command is invalid, is it possible to just throw the exception straight?

Comment thread src/main/java/ManageInputs.java Outdated
}
}

public ManageInputs(ArrayList<Task> tasks, int index, String line) throws IOException, UnexpectedCommandException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This function is doing quite a fair bit of heavy lifting.

It's very long, which usually indicates that perhaps you could apply SLAP more here.

To aid you in achieving SLAP, here are some guiding questions...

  1. What parts of the code is repetitive? i.e. virtually the same for each if/else block you have
  2. What part of the code does a particular function that can be isolated into a function? (like printing tasks, or doing something to the file?)

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

if (inputs[0].equals("mark")) {//mark as done
isValidCommand = true;
int idx = Integer.parseInt(inputs[1]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

index and idx are being used in the code but seem to be referring to different things. It's not too clear what they really mean! Do consider how you could make this function more readable!

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