Skip to content

[Syed Muhammad Aljunied] Duke Increments#341

Open
muhammadaljunied wants to merge 56 commits intonus-cs2103-AY1920S1:masterfrom
muhammadaljunied:master
Open

[Syed Muhammad Aljunied] Duke Increments#341
muhammadaljunied wants to merge 56 commits intonus-cs2103-AY1920S1:masterfrom
muhammadaljunied:master

Conversation

@muhammadaljunied
Copy link
Copy Markdown

No description provided.

j-lum and others added 24 commits August 6, 2019 15:25
Add toolVersion block in to Gradle code sample to prevent errors.
Gradle defaults to an empty stdin which results in runtime exceptions
when attempting to read from `System.in`. Let's add some sensible
defaults for students who may still need to work with the standard
input stream.
Add configuration for console applications
Added Gradle Support
Added Checkstyle plugin
Added Shadow plugin
Added JUnitTest Dependency
Added Gradle Support
Added Checkstyle plugin
Added Shadow plugin
Added JUnitTest Dependency
Added Echo
Added Exit
Implemented "List all task" feature
Implemented "List all task" feature
Implemented pattern matching for commands and arguments with regex
Abstracted out Commands to reduce excessive if-else for executing commands
Specific commands print their relevant messages
Added Mark as completed
Resolved Checkstyle Errors
Added package seedu.duke.trackables ahead of level-4 requirements
Refactored task object for abstraction
Refactored Command objects to reflect abstraction of task object.
Updated patterns for Regex
Added Support for Event, Todo, Deadline
Added Error Abstractions for Common errors (Invalid Command, Invalid Arguments)
Duke specific exceptions are thrown with original cause (if available) to provide more useful stack trace.

** Forgot to commit Level 4, thus tagged as level 4 and 5)
Copy link
Copy Markdown

@TSAI-HSIAO-HAN TSAI-HSIAO-HAN left a comment

Choose a reason for hiding this comment

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

The overall Java style seems correct. Can break some lines to increase readability.

@Override
public void execute(List<Task> tasks) {
tasks.add(deadline);
echo(
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 indentation for wrapped lines in execute method should be 8 spaces.

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.

Line 20 should be together with Line 19.

@Override
public void execute(List<Task> tasks) {
tasks.get(taskId).markAsDone();
echo(
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 indentation for wrapped lines in execute method should be 8 spaces.

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.

Line 19 should be together with Line 18.

@Override
public void execute(List<Task> tasks) {
tasks.add(event);
echo(new String[] {
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 indentation for wrapped lines in execute method should be 8 spaces.

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.

This is the indentation that CheckStyle approves.

Line 19 at level 8
Line 20-22 at level 12
Line 23 at level 8 (to close the String array instantiation)

Copy link
Copy Markdown

@ChrisKheng ChrisKheng left a comment

Choose a reason for hiding this comment

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

Last note: In the DeleteCommand class, maybe you want to consider not to decrease the index of the task by 1? Cuz I think maybe in the future you may need to retrieve the index of the task from the command and hence it may cause confusion or bug when the index is different from the "surface" index (i.e. the id starts from 1 when displaying the tasks). You can decrease the index by 1 in the execute() method when trying to retrieve the task.

Overall, I think you could improve on the structure of the program by separating the logic of the program into more classes (Single Responsibility Principle). This can make it easier to manage the program's code, especially when the program scale becomes larger and larger. All the best and cheers!

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Duke {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Regarding Duke class, maybe you want to separate the functionalities in it into more classes? Like Storage, Parser etc. I think there are too many functionalities in the Duke class and it doesn't really correspond to the Single Responsibility principle in SOLID. It may make the process of changing the program's code to fit new requirement harder as it may be quite hard to locate the right piece of code to change among the extensive lines of code.

Also, I think the purpose of Duke class should act like a body which links all its parts(Storage, Parser, TaskList) together and not doing too much of logic. This concept may help you to refactor your code.

* Prints out the message.
* @param messages Array of messages to show.
*/
protected void echo(String[] messages) {
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 want to separate the logic of printing, handling database into more classes such as Storage and Parser? This would reduce the responsibility of the Command classes and may aid in coding or making changes when doing further extensions of the program.


@Override
public void execute(List<Task> tasks) {
tasks.get(taskId).markAsDone();
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 want to assign the task that you have retrieved to a variable so that later you can directly call toString() on it? This will then prevent from doing two get(), which means traversing twice through the list, which can increase the complexity of the solution.


import java.util.List;

public class TodoCommand extends Command {
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 it's good to rename the TodoCommand, DeadlineCommand and EventCommand to maybe AddToDoCommand, AddDeadlineCommand and AddEventCommand? This can improve the clarity of the code.

public class Task {
protected String description;
protected boolean isDone;

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 it would be good to make an enum to label the respective classes (ToDo, Deadline, Event)? This may help in the future when you want to extend your program.


public class Event extends Task {

protected String 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.

Maybe you want to use another name such as "time" instead of "at" for the string which stores the date? I think this would improve the clarity of your code.


public class Deadline extends Task {

protected String 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.

Maybe you want to use "deadline" instead of "by" to improve the clarity of the code?

muhammadaljunied and others added 30 commits September 12, 2019 14:38
Resolved Checkstyle Issues
Refactored Command Arguments parsing into respective command objects
Error handling now cleaner with more specific error messages.
# Conflicts:
#	src/main/java/seedu/duke/Duke.java
#	src/main/java/seedu/duke/trackables/Deadline.java
Abstracted out Ui and printing operations to Ui.java from Duke.java
Updated Exceptions with new constructor e*(String message)
Updated Javadocs.
Updated UI to handle reading inputs.
Refactored IndexOutOfBounds error handling to TaskList from DeleteCommand and DoneCommand.
* branch-JavaDoc:
  Added Complete JavaDoc.
* branch-CodingStandard:
  Updated codebase to match Java Coding Standards.

# Conflicts:
#	src/main/java/seedu/duke/commands/AddCommand.java
#	src/main/java/seedu/duke/trackables/Event.java
Added missing Javadocs.
Added UI tweaks
Added Stop handler when user closes using window close
Added wrapping width for text node in UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants