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

[jednghk] iP #320

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

[jednghk] iP #320

wants to merge 32 commits into from

Conversation

jednghk
Copy link

@jednghk jednghk commented Jan 27, 2023

Duke

Some people look good from far, but are far from good. (Source)

Have you ever wanted to:

  1. Not use much nicer UIs for your event planning 🤔
  2. Make your life harder?

Then this is the app for you!

As a software engineering project done by an inexperienced programmer, Duke can:

  • Record your todos, deadlines, events, but only when you follow a very specific format

  • That's about it!

  • Here's a checkbox for you to click for fun

If you're reading this far for some reason, here's a code block for you to analyse:

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

Copy link

@bokuanT bokuanT left a comment

Choose a reason for hiding this comment

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

LGTM. 👍
Coding standards are adhered to well and I like how you are making use of OOP by extracting the task list into the TaskList class.

taskToMark.unmark();
}

public String getTaskList() {
Copy link

Choose a reason for hiding this comment

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

Just picking a nit but maybe you could consider renaming this method to getTaskListString. Might be less confusing in the future if you ever need a method to return the List<Task> taskList.

while (true) {
String userInput = sc.nextLine().toLowerCase();
String[] command = userInput.split(" ", 10);
switch (command[0]) {
Copy link

Choose a reason for hiding this comment

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

It's good that you adhered to the CS2103 java coding standards for switch statements.

import java.util.List;

public class TaskList {
private List<Task> taskList = new LinkedList<>();
Copy link

Choose a reason for hiding this comment

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

Was there a particular reason why you chose to use a LinkedList<E> over an ArrayList<E>?

+ "____________________________________________________________");
}

private void greet() {
Copy link

Choose a reason for hiding this comment

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

Would you consider encapsulating all of Duke's interactions with the user into a separate class? The class could be the Ui class, containing the methods greet(), printExitMessage(), etc.

}
}
}
}

Choose a reason for hiding this comment

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

For the project structure, I think it will be good to move Tasks (Deadline Todo...) to a package and move others to another.

import java.io.*;
/** Handles the storage and retrieval of tasks. */
public class Storage {
TaskList taskList;

Choose a reason for hiding this comment

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

better to add public/private

Event event = (Event) this;
return String.format("%c|%b|%s|%s|%s", taskType, isDone, taskName, event.getFrom(), event.getTo());
}
}

Choose a reason for hiding this comment

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

For this part, to use a switch-case block is concise

public void unmarkTask(int taskIndex) {
Task taskToMark = this.getTask(taskIndex);
taskToMark.unmark();
}

Choose a reason for hiding this comment

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

more comments expected for the methods above

}
}
}
}

Choose a reason for hiding this comment

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

Also the main class should look more concise, the code inside the while loop could be extracted to Parser or another class.

The getResponse() method body does not adhere to SLAP and has an arrowhead style code. This makes the code messier and harder to debug.

Refactoring the method body will improve code quality.

Let's create a Command class which handles the execution of the user input, and split the code into their respective methods to mitigate the arrowhead style code.
Abstract getResponse() method body
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.

None yet

3 participants