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

[jweeyh] iP #162

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

[jweeyh] iP #162

wants to merge 40 commits into from

Conversation

jweeyh
Copy link

@jweeyh jweeyh commented Jan 24, 2023

No description provided.

Copy link

@dfordarius dfordarius left a comment

Choose a reason for hiding this comment

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

Overall code quality is pretty good! Good OOP with some mixor fixes to be done! Keep up the good work 😄

Comment on lines 7 to 9
private Storage storage;
private DukeList dukeList;
private Ui ui;

Choose a reason for hiding this comment

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

Perhaps these 3 variables can be final?

Comment on lines 36 to 42
}
System.out.println("Sure, Imma add that real quick");
System.out.println(task);
list.add(task);
System.out.println("Now you've got " + list.size() + pluralTask(list.size()));
System.out.println(new TextBorder(""));
}

Choose a reason for hiding this comment

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

Maybe you can move all the prints into the Ui class? After all you have a Ui class and the Ui class should deal with interactions with the user

public class MarkCommand extends Command{

private String task;
private boolean marker;

Choose a reason for hiding this comment

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

Maybe change it to a more boolean sounding name like "isMarked" ?

Comment on lines 36 to 50
if (inputText.equals("bye")) {
return new ExitCommand(this.dukelist, this.storage);
} else if (first.equals("list")){
return new ListCommand(this.dukelist);
} else if (first.equals("mark")) {
return new MarkCommand(array[1], true, dukelist);
} else if (first.equals("unmark")) {
return new MarkCommand(array[1], false, dukelist);
} else if (first.equals("delete")){
return new DeleteCommand(array[1], dukelist);
} else if (first.equals("find")) {
return new FindCommand(array[1], dukelist);
} else {
if (array.length != 2) {
if (first.equals("todo") || first.equals("deadline") || first.equals("event")) {

Choose a reason for hiding this comment

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

Maybe u can consider using switch for this part so it looks cleaner and improve readability?

Comment on lines 23 to 27
public void add(String type, String s) {
Task task = new Task();
if (type.equals("todo")) {
task = new Todo(s);

Choose a reason for hiding this comment

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

Maybe this method could be named to be more descriptive like "addTask"

@jweeyh
Copy link
Author

jweeyh commented Feb 2, 2023 via email

Copy link

@bryansendeavour bryansendeavour left a comment

Choose a reason for hiding this comment

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

Code looks good, some minor suggestions made feel free to disregard if found unnecessary. Cheers!

public class MarkCommand extends Command{

private String task;
private boolean marker;

Choose a reason for hiding this comment

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

Maybe isMarked could be used for your boolean variable?

Comment on lines 3 to 4
import task.*;
import exception.*;

Choose a reason for hiding this comment

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

Would it be better to import all the classes instead?

Comment on lines 15 to 21
private String pluralTask (int size) {
if (size == 1) {
return " task.";
} else {
return " tasks.";
}
}

Choose a reason for hiding this comment

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

Would it be better to put this in your Ui class?

@@ -0,0 +1,66 @@
package duke;

import command.*;

Choose a reason for hiding this comment

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

Maybe to conform to conventions you would like to import each class separately?


public class TextBorder {
String text;
String border = "// / / // / / // / / // / / // / / // / / // /";

Choose a reason for hiding this comment

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

Maybe this can be static final?

jweeyh and others added 6 commits February 6, 2023 20:46
# Conflicts:
#	src/main/java/command/ExitCommand.java
#	src/main/java/command/FindCommand.java
#	src/main/java/command/ListCommand.java
#	src/main/java/command/MarkCommand.java
#	src/main/java/duke/DukeList.java
Add Assert to SaveList in Storage
Copy link

@DerenC DerenC left a comment

Choose a reason for hiding this comment

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

A brief review of code quality, mainly on these problems
a. weak SLAP
b. arrow-head style code
c. too-long methods
d. too-deep nesting

Comment on lines 29 to 56
public DukeList retrieveList (Ui ui) {
try {
if ((new File(path)).exists()) {
FileInputStream fis = new FileInputStream(path);
ObjectInputStream ois = new ObjectInputStream(fis);
try {
DukeList savedDukeList = (DukeList) ois.readObject();
savedDukeList.setUi(ui);
return savedDukeList;

} catch (IOException e) {
ui.addStatement("Creating new save");
}
}

} catch (FileNotFoundException e) {
ui.addStatement("Hey sorry man, something's off bout you're save data.");
ui.addStatement(e.toString());
} catch (IOException e) {
ui.addStatement("Yo something's up with your I/O, gotta get it checked before doing this.");
ui.addStatement(e.toString());
System.out.println(e);
} catch (ClassNotFoundException e) {
ui.addStatement("Hey I can't find your object class.");
ui.addStatement(e.toString());
}
return new DukeList(ui);
}
Copy link

Choose a reason for hiding this comment

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

Maybe can make this double nested try-catch block into a single level try-catch

Comment on lines 36 to 92
public void start(Stage primaryStage) throws Exception {
scrollPane = new ScrollPane();
dialogContainer = new VBox();
scrollPane.setContent(dialogContainer);

userInput = new TextField();
sendButton = new Button("Send");

AnchorPane mainLayout = new AnchorPane();
mainLayout.getChildren().addAll(scrollPane, userInput,sendButton);

scene = new Scene(mainLayout);
primaryStage.setScene(scene);
primaryStage.show();

//2
primaryStage.setTitle("Duke");
primaryStage.setResizable(false);
primaryStage.setMinHeight(600.0);
primaryStage.setMinWidth(400.0);

mainLayout.setPrefSize(400.0, 600.0);

scrollPane.setPrefSize(385, 535);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);

scrollPane.setVvalue(1.0);
scrollPane.setFitToWidth(true);

dialogContainer.setPrefHeight(Region.USE_COMPUTED_SIZE);

userInput.setPrefWidth(325.0);

sendButton.setPrefWidth(55.0);

AnchorPane.setTopAnchor(scrollPane, 1.0);

AnchorPane.setBottomAnchor(sendButton, 1.0);
AnchorPane.setRightAnchor(sendButton, 1.0);

AnchorPane.setLeftAnchor(userInput , 1.0);
AnchorPane.setBottomAnchor(userInput, 1.0);

sendButton.setOnMouseClicked((event) -> {
handleUserInput();
});

userInput.setOnAction((event) -> {
handleUserInput();
});

dialogContainer.getChildren().addAll(
new DialogBox(new Label("Waddup the name's Duncan. Sorry but Duke couldn't make it, had a pretty bad stomach-ache."), new ImageView(duncan)),
new DialogBox(new Label("So what do you need bro?"), new ImageView(duncan))
);
}
Copy link

Choose a reason for hiding this comment

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

While the use of SLAP is quite good here, the method seems a bit too long

Comment on lines 50 to 63
} else {
if (array.length != 2) {
if (first.equals("todo") || first.equals("deadline") || first.equals("event")) {
throw new EmptyDescriptionException("Sorry, your " + first + " task description is missing.");

} else {
throw new UnknownInputException("Hmm, I'm not sure what you're saying man.");

}
}
return new AddCommand(array[0], array[1], dukelist);

}
} catch (ArrayIndexOutOfBoundsException e) {
Copy link

Choose a reason for hiding this comment

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

This part of the code seems a bit too deeply nested

jweeyh and others added 14 commits February 10, 2023 14:29
There was text present that contained the default String drawing of Duke, which was relevant only in CLI, but has since become redundant with the new GUI.

This currently unused text is thus deleted in accordance with the coding standard to remove unused and outdated code.

Let's try to find other instances in the code which could be simplified and refactored.
At the start of the run function, it is important that the statements in the Ui are cleared so that previous commands would not be executed unintentionally.

An assert is thus placed after ui.clearStatements

This is done to confirm that the Ui statements have been cleared
Add assert to the run function in Duke
# Conflicts:
#	src/main/java/duke/Parser.java
As a matter of housekeeping and storage, there might be tasks that need to be removed from the current list, but may be retrieved in the future

An archive function that creates and stores another DukeList is implemented

As an extension, the archive function can help to store redundant tasks in the main list into a separate list for future retrieval
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

4 participants