Skip to content

[Cheong Yee Ming] iP#462

Open
CheongYeeMing wants to merge 36 commits into
nus-cs2103-AY2122S1:masterfrom
CheongYeeMing:master
Open

[Cheong Yee Ming] iP#462
CheongYeeMing wants to merge 36 commits into
nus-cs2103-AY2122S1:masterfrom
CheongYeeMing:master

Conversation

@CheongYeeMing

@CheongYeeMing CheongYeeMing commented Aug 25, 2021

Copy link
Copy Markdown

Duke

"The way to get started is to quit talking and begin doing." -Walt Disney (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 (coming soon)
  • 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);
    }
}

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

LGTM. Just some nits to fix.

Comment thread src/main/java/duke/parser/Parser.java Outdated
}

/**
*

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 the method summary missing?

Comment thread src/main/java/duke/storage/Storage.java Outdated
* Saves tasks in TaskList to local directory.
* Folder and file will be created if not already present.
*
* @param taskList

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 the description of taskList missing?

Comment thread src/main/java/duke/ui/Ui.java Outdated
* @param task Task to be added into task list.
* @param taskLeft Total number of tasks in the task list.
*/
public void taskAddedMessage(Task task, int taskLeft) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps this method name can be changed to a verb (i.e. printTaskAddedMessage)?
Similarly for some of the methods below.

/**
* Constructor for an AddCommand.
*
* @param taskList Handles all operations regarding tasks.

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 like how the descriptions have the same indentation which makes it easy to read. 👍

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

LGTM, just some minor cosmetic issues to consider 🥇

Comment thread src/main/java/duke/command/Command.java Outdated
*
* @throws DukeException when an error occurs.
*/
public abstract void runCommand() 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.

Maybe you can consider renaming the method execute or simply run to clearly distinguish the method to run the command from the type of command (i.e. AddCommand, DeleteCommand etc.)

Comment thread src/main/java/duke/parser/Parser.java Outdated
* @throws DukeException If user input is invalid.
*/
public Command parseUserInput(String userInput) throws DukeException {
String[] splitUserInput = userInput.split(" ");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider using a noun like userInputTokens instead of splitUserInput

Comment thread src/main/java/duke/parser/Parser.java Outdated
Comment on lines +101 to +143
case DEADLINE:
try {
int byIndex = commandDetails.indexOf("/by") - 1 ;
if (byIndex <= 0) {
throw new NoDateTimeException(ui);
}
String deadlineDetails = commandDetails.substring(0, byIndex);
if (deadlineDetails.isBlank()) {
throw new NoTaskDescriptionException(ui);
}
try {
LocalDateTime by = LocalDateTime.parse(commandDetails.substring(deadlineDetails.indexOf("by") + 3),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
return new Deadline(deadlineDetails, false, by);
} catch (DateTimeParseException e) {
throw new InvalidDateTimeException(ui);
}
} catch (StringIndexOutOfBoundsException e) {
throw new NoTaskDescriptionException(ui);
}


case EVENT:
try {
int atIndex = commandDetails.indexOf("/at") - 1 ;
if (atIndex <= 0) {
throw new NoDateTimeException(ui);
}
String eventDetails = commandDetails.substring(0, atIndex);
if (eventDetails.isBlank()) {
throw new NoTaskDescriptionException(ui);
}
try {
LocalDateTime at = LocalDateTime.parse(commandDetails.substring(eventDetails.indexOf("at") + 3),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
return new Event(eventDetails, false, at);
} catch (DateTimeParseException e) {
throw new InvalidDateTimeException(ui);
}
} catch (StringIndexOutOfBoundsException e) {
throw new NoTaskDescriptionException(ui);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The code in the Deadline and Event cases are very similar hence I think you could combine both into one case; alternatively, assuming all taskType inputs are valid, consider the ToDo case first and let the Deadline and Event be the default. To account for the 'by' and 'at' issue, maybe you can define an auxiliary delimiter string, if event then the string is 'at', else 'by'. This might help significantly reduce code duplication 👍🏼

*/
public class TaskList {

private ArrayList<Task> 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.

Perhaps tasks would be more descriptive than list

Comment thread src/main/java/duke/parser/Parser.java Outdated
Comment on lines +57 to +83
case "list":
return new ListCommand(taskList, storage, ui);

case "bye":
return new ExitCommand(taskList, storage, ui);

case "deadline":
return new AddCommand(taskList, storage, ui, parseTaskInput(TaskType.DEADLINE, userInput));

case "event":
return new AddCommand(taskList, storage, ui, parseTaskInput(TaskType.EVENT, userInput));

case "todo":
return new AddCommand(taskList, storage, ui, parseTaskInput(TaskType.TODO, userInput));

case "done":
return new DoneCommand(taskList, storage, ui, Integer.parseInt(splitUserInput[1]));

case "delete":
return new DeleteCommand(taskList, storage, ui, Integer.parseInt(splitUserInput[1]));

case "find":
return new FindCommand(taskList, storage, ui, userInput.substring(userInput.indexOf(" ") + 1));

default:
throw new NoSuchCommandException(ui);
}

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 like how clean and neat this is 👍🏼

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

LGTM! Just a few nits with the JavaDocs but generally looks great!

import duke.ui.Ui;

/**
* Command to add a task to the task 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.

I think it would be good to document down what is contained in each Command

Comment thread src/main/java/duke/command/Command.java Outdated
protected final Ui ui;

/**
* Constructor for a DukeCommand.

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 mention a DukeCommand in the JavaDocs, but the constructor creates a Command, so it might be good to streamline this and standardize to 1 name for the Command class

*/
public class Deadline extends Task {

protected final LocalDateTime by;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A name like by is not really descriptive enough. Maybe consider something like deadline.

*/
public class Event extends Task {

protected final LocalDateTime at;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as by, at is not very descriptive

CheongYeeMing and others added 10 commits September 7, 2021 04:52
No assertions used in code.

Assertions help detect programmer mistakes.

Adding assert statement to the following classes:
* `AddCommand`
* `DeleteCommand`
* `DoneCommand`
* `Parser`
* `Storage`
* `Deadline`
* `Task`
* `TaskList`

Assert statements are added in cases where `null` is passed into the respective `Task` constructors, detects empty tasks.
Nested class.

Outer class now had 2 responsibilities. Breaches the Single Responsibility Principle.

Extracting nested class `ExitProgram` within `Main` class.

Avoid nesting of classes, adhere to Single Responsibility Principle.
For loops used for iteration.

Too many lines of code, does not look good.

Replace for loops with streams.

Benefits of streams:
* Write functions at more abstract level
* Make code more expressive
* Less verbose code
* More Intuitive code
* Less error prone code
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