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

[ Hardik Narang ] iP #489

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

Conversation

naranghardik16
Copy link

@naranghardik16 naranghardik16 commented Aug 27, 2021

Duke

"Your mind is for having ideas, not holding them." - David Allen (source)

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

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

All you need to do is,

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

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 static void main(String[] args) {
      new Duke(DUKE_TXT).runDuke();
}

public static void readInput(String userInput){

// Get command from the userInput
String[] splitLine = userInput.split(" ", 2);

Choose a reason for hiding this comment

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

Shouldn't a plural noun be used for the list of substrings?

import java.time.format.DateTimeFormatter;

public class Event extends Task{
private LocalDateTime at;

Choose a reason for hiding this comment

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

I know its easy to tell from the context, but maybe the variable name can be a little more descriptive? I noticed this in Deadline.java too 👍

Copy link

@codecodecoder78 codecodecoder78 left a comment

Choose a reason for hiding this comment

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

Generally great job for abstraction, few nits on styling to fix for clarity!

data/duke.txt Outdated
@@ -0,0 +1,8 @@
T | 1 | new

Choose a reason for hiding this comment

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

Should the save files be uploaded to github?

Choose a reason for hiding this comment

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

You should leave duke.txt in the .gitignore file.

throw new DoneAlreadyException();
}

// Mark the index as done

Choose a reason for hiding this comment

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

Perhaps proper javadocs could be added so IDE can display the documentation with all the information?

userInput = userInput.replaceAll( RegexType.START_LINE_REGEX.getRegexType() + command + RegexType.SPACE_REGEX.getRegexType(), "");

// Check the command type then execute the commands
if(userInput.equals(InputType.LIST.getInputType())) {

Choose a reason for hiding this comment

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

Could this list of checks better be served with a switch statement to improve readability?

Copy link

@NayLin-H99 NayLin-H99 left a comment

Choose a reason for hiding this comment

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

I really liked that you have done a lot of abstraction in your code.

import duke.InputType;
import duke.Parser;
import duke.Storage;
import duke.tasks.*;

Choose a reason for hiding this comment

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

Wildcard Imports are suggested against in this module. Perhaps you can set your IDE to not "optimise" imports automatically.
image

try {
return command.execute();
} catch (Exception e) {
return new CommandResult(e.getMessage(), false, null);

Choose a reason for hiding this comment

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

Did you not overload your constructor? Do you need to input the "null" argument here?

userInput = in.nextLine();

// While the input is not "bye", add input to array of tasks and get another input
while (!userInput.equals(InputType.BYE.getInputType())) {

Choose a reason for hiding this comment

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

I think the readibility of this line can be improved by using the "bye" string directly or abstracting this into an ExitCommand as suggested under the specifications. Don't you think so?

Comment on lines +25 to +27
if(arguments.equals(InputType.LIST.getInputType())) {
return new ListCommand(taskList);
}

Choose a reason for hiding this comment

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

Doing this kind of defeats the purpose of using enum, right? Instead of using enum purely as strings, I suggest parsing the user input into enum, then using the enum to return the appropriate commands.

An additional suggestion is to use switch case, which is recommended for enum since you can do something like:

Suggested change
if(arguments.equals(InputType.LIST.getInputType())) {
return new ListCommand(taskList);
}
switch (inputType) {
case LIST:
return new ListCommand(taskList);

}
return new EmptyCommand(taskList);
}
}

Choose a reason for hiding this comment

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

At the end of every file, you should leave a newline! 😄

Comment on lines 59 to 64
if (commandResult.isUpdated()) {
taskList = commandResult.getTaskList();
String errorMessage = storage.writeToFile(taskList);

ui.printMessage(errorMessage);
}

Choose a reason for hiding this comment

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

I don't think you need to check for this. You can save the file after every command.

import duke.PrintType;
import duke.tasks.TaskManager;

public class EmptyCommand extends Command{

Choose a reason for hiding this comment

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

I don't think you need to create a class just to handle an empty command? I suggest just throwing a DukeException for unrecognised strings, since you are using Regex anyways.

* @return - the message of acknowledgement in String form
* @throws TodoException - if the description is empty
*/
public String addTodo(String userInput) throws TodoException {

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 is the point of having individual command classes where you are doing all the commands under the Task Manager itself?

/**
* Class to maintain the UI of the list of tasks
*/
public class TaskManagerUi {

Choose a reason for hiding this comment

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

Your UI class should handle interactions with the user? Is this not just a tuple?

*/
public class Todo extends Task {
private TaskType type = TaskType.TODO;
public Todo (String description){

Choose a reason for hiding this comment

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

Try to have consistent formatting 😄

Suggested change
public Todo (String description){
public Todo (String description) {

naranghardik16 and others added 20 commits September 20, 2021 08:12
Ensure the method/class header comments follow the format specified in the coding standard.

Points improved:
- The Javadoc comment is minimal.
- Include tags wherever required and follow the particular order.
Make use of assert feature to document important assumptions that should hold at various points in the code.

Refer to this for more details on Java assertions:
https://www.geeksforgeeks.org/assertions-in-java/
Provide a way to attach priorities to tasks such as Low or High
This will help the user to prioritize the tasks and become more efficient
A task with High priority needs to be done first
A task with Low priority needs to be done at the last.

Have implemented the extension C-Priority

Refer to the other list of extensions here:
https://nus-cs2103-ay2122s1.github.io/website/se-book-adapted/projectDuke/index.html#extensions-category-b
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