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

[Han Jiyao] iP #303

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

[Han Jiyao] iP #303

wants to merge 63 commits into from

Conversation

HanJiyao
Copy link

@HanJiyao HanJiyao commented Jan 30, 2022

Duke Chat

“Your mind is for having ideas, not holding them.” – David Allen (source)

DukePro frees your mind of having to remember things you need to do. It's,

  • text-based
  • easy to learn
  • FAST SUPER FAST to use

All you need to do is,

  1. download it from here.
  2. double-click it.
  3. add your tasks.
  4. let it manage your tasks for you 😉

And it is FREE!

Features:

  • Managing tasks
  • Managing deadlines
  • Reminders (coming soon)

If you Java programmer, you can use it to practice Java too. Here's the main method:

public class Main {
    public static void main(String[] args) {
        Application.launch(MainApp.class, args);
    }
}

Copy link

@hsiaojietng hsiaojietng left a comment

Choose a reason for hiding this comment

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

LGTM. If you're able to encapsulate the behaviour of all the actions of Duke then it would be better

@Override
public String toString() {
return "["+Type.D+"]" + super.toString() + " (by: " + by + ")";
}

Choose a reason for hiding this comment

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

Well done on the naming of variables, they are easily read!


case "deadline":
StringBuilder deadline = new StringBuilder();
StringBuilder deadlineBy = new StringBuilder();

Choose a reason for hiding this comment

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

Maybe can encapsulate this functionality in another class if you want

this.at = at.trim();
}

public Event(String task, boolean done) {

Choose a reason for hiding this comment

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

Easy to read!

Copy link

@9teMare 9teMare left a comment

Choose a reason for hiding this comment

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

Overall good job 🙂!
Just a few points to mention:

  • OOP practices can be implemented better
  • Coding standard should be followed consistently
  • Seems like you are a little bit behind schedule, looking forward to your GUI implementation!

}

public void execute(TaskList tasks, Ui ui, Storage storage) {
tasks.add(new Deadline(newDeadline.getTask(), newDeadline.getDate()));
Copy link

Choose a reason for hiding this comment

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

I like how you use getter method to keep fields in Deadline class private. Good job 👍!

public void execute(TaskList tasks, Ui ui, Storage storage) {
tasks.add(new Deadline(newDeadline.getTask(), newDeadline.getDate()));
storage.saveTaskList(tasks);
ui.showMessage("Got it. I've added this task: \n "
Copy link

Choose a reason for hiding this comment

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

Extra blank spaces after the new line character is a little bit misleading, maybe can move these blank spaces into the next line.

tasks.add(new Deadline(newDeadline.getTask(), newDeadline.getDate()));
storage.saveTaskList(tasks);
ui.showMessage("Got it. I've added this task: \n "
+ tasks.getByIndex(tasks.getSize() - 1) + "\n Now you have " + tasks.getSize() + " tasks in the list.");
Copy link

Choose a reason for hiding this comment

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

Not sure if this line of code is too long for our coding standard, but generally try to break up a long line of code like this.

import task.TaskList;
import ui.Ui;

public class ErrorCommand extends Command {
Copy link

Choose a reason for hiding this comment

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

I love your implementation of having an abstract class Command and various other commands that extend it, however, personally I do not think an ErrorCommand is considered as a Command, because if you think about it, it is not like the user wants to input something intentionally that triggers this. The code works perfectly fine, it's just that why not throw exception directly when parsing the user input in the first place, instead of having recognized that the user input something invalid but still parse it to a Command?

Comment on lines 12 to 18
@Override public void execute(TaskList tasks, Ui ui, Storage storage) {
ui.showExitMessage();
}

@Override public boolean isExit() {
return true;
}
Copy link

Choose a reason for hiding this comment

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

The @Override tag should occupy its own line.

import command.ExitCommand;
import command.MarkCommand;
import command.ListCommand;
import data.DukeException;
Copy link

Choose a reason for hiding this comment

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

Not sure if this line follows the import order in checkStyle.

}
break;
case "D":
Deadline newDeadline = new Deadline(input.get(2).trim(), LocalDate.parse(input.get(3).trim(), formatter));
Copy link

Choose a reason for hiding this comment

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

Sufficient comment here can probably improve the readability by a lot.

import java.time.format.DateTimeFormatter;

public class Deadline extends Task {
protected LocalDate by;
Copy link

Choose a reason for hiding this comment

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

private should be a better accesser here than protected because there are no other classes extending from Deadline, therefore, the only object that will access this field is of type Deadline. Declaring this field as final should also be a good practice because the time should not be changed after new() an object.


@Override
public String saveData() {
int done = super.done? 1 : 0;
Copy link

Choose a reason for hiding this comment

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

Declaring this as boolean isDone might be better.

Comment on lines 19 to 25
public Task mark() {
return new Task(task, true);
}

public Task unmark() {
return new Task(task, false);
}
Copy link

Choose a reason for hiding this comment

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

Not too sure about the rationale behind the need to new() an object, (same for Deadline Event and Todo), why not just simply set the done field as true or false, all the children of Task share the same behaviour and they can just access mark() and unmark() straight away.

HanJiyao and others added 30 commits February 11, 2022 01:18
There is a method that previous used as textUI to convert cli command
into console output. This method is never used as GUI has implemented.

Removing all these unused code improves the code quality.

As a step towards such unification, let's remove those unused code
blocks in their respective classes. Doing so will make the code easier
to understand.
Duke: getResponse() add assertion
Parser: parse() add assertion
Storage: load() add assertion
Ui: showMessage() add assertion
MainWindow: add DukeException

Add assertion failure indicates possible bug

Use assert feature aim to document important
assumptions that should hold at various points in the code.

Let's update the methods with assertions.

Using assertion is preferable.
There is a name error from prepareAddTodo() to prepareAddToDo().

Fixing this name error will resolve the application cannot run.

Let's update the method name inside the Parse class.
Mark an item as a high normal low priority
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