@KristopherPTaslim We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
No easy-to-detect issues 👍
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/duke/Duke.java lines 38-115:
public void start(Stage stage) {
storage.load();
//Taken from JavaFX Tutorial @SE-EDU/guides
//Step 1. Setting up required components
//The container for the content of the chat to scroll.
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);
stage.setScene(scene);
stage.show();
//Step 2. Formatting the window to look as expected
stage.setTitle("Duke");
stage.setResizable(false);
stage.setMinHeight(600.0);
stage.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);
// You will need to import `javafx.scene.layout.Region` for this.
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);
//Adding Welcome message
startMessage();
//Step 3. Add functionality to handle user input.
sendButton.setOnMouseClicked((event) -> {
dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
userInput.clear();
});
userInput.setOnAction((event) -> {
dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
userInput.clear();
});
//Scroll down to the end every time dialogContainer's height changes.
dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));
//Part 3. Add functionality to handle user input.
sendButton.setOnMouseClicked((event) -> {
handleUserInput();
});
userInput.setOnAction((event) -> {
handleUserInput();
});
}
Example from src/main/java/duke/Parser.java lines 26-126:
public String execute(String input) {
String[] checkCase = input.split(" ");
switch (checkCase[0].toLowerCase()) {
case ("list"):
return taskList.showTask();
case ("mark"):
try {
int index = Integer.parseInt(checkCase[1]) - 1;
Task tasks = taskList.getTaskArray().get(index);
String output = tasks.mark();
taskList.getTaskArray().set(index, tasks);
return output;
} catch (ArrayIndexOutOfBoundsException e) {
return ui.showInvalidInput();
} catch (IndexOutOfBoundsException e) {
return ui.showInvalidInput();
}
case ("unmark"):
try {
int index = Integer.parseInt(checkCase[1]) - 1;
Task tasks = taskList.getTaskArray().get(index);
String output = tasks.unmark();
taskList.getTaskArray().set(index, tasks);
return output;
} catch (ArrayIndexOutOfBoundsException e) {
return ui.showInvalidInput();
} catch (IndexOutOfBoundsException e) {
return ui.showInvalidInput();
}
case ("todo"):
try {
String stringSliced = parseString(input);
Todo todoTask = new Todo(stringSliced);
taskList.addTask(todoTask);
String noOfTask = String.valueOf(taskList.getTaskArray().size());
return ui.showAddedMessage(todoTask, noOfTask);
} catch (StringIndexOutOfBoundsException e) {
return ui.showTodoError();
}
case ("deadline"):
try {
String parsedTime = parseByCondition(input);
String convertedTime = convertTime(parsedTime);
String stringSliced = parseString(input);
Deadline deadlineTask = new Deadline(stringSliced, convertedTime);
taskList.addTask(deadlineTask);
String noOfTask = String.valueOf(taskList.getTaskArray().size());
return ui.showAddedMessage(deadlineTask, noOfTask);
} catch (StringIndexOutOfBoundsException e) {
return ui.showDeadlineError();
}
case ("event"):
try {
String parsedTime = parseByCondition(input);
String convertedTime = convertTime(parsedTime);
String stringSliced = parseString(input);
Event eventTask = new Event(stringSliced, convertedTime);
taskList.addTask(eventTask);
String noOfTask = String.valueOf(taskList.getTaskArray().size());
return ui.showAddedMessage(eventTask, noOfTask);
} catch (StringIndexOutOfBoundsException e) {
return ui.showEventError();
}
case("delete"):
try {
int index = Integer.parseInt(checkCase[1]) - 1;
Task task = taskList.getTaskArray().get(index);
taskList.deleteTask(index);
String noOfTask = String.valueOf(taskList.getTaskArray().size());
return ui.showDeletedMessage(task, noOfTask);
} catch (ArrayIndexOutOfBoundsException e) {
return ui.showDeleteError();
}
case("find"):
String stringSliced = parseString(input);
return ui.showFindMessage(taskList.findTask(stringSliced));
case("view"):
String parsedDate = parseString(input);
String convertedDate = convertDate(parsedDate);
return ui.showScheduleMessage(taskList, convertedDate);
case("bye"):
return ui.showGoodbyeMessage();
default:
return ui.showDefaultMessage();
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
Example from src/main/java/duke/Duke.java lines 117-122:
/**
* Iteration 1:
* Creates a label with the specified text and adds it to the dialog container.
* @param text String containing text to add
* @return a label with the specified text that has word wrap enabled.
*/
Example from src/main/java/duke/Duke.java lines 131-135:
/**
* Iteration 2:
* Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
* the dialog container. Clears the user input after processing.
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Message (Subject Only)
No easy-to-detect issues 👍
Aspect: Binary files in repo
Suggestion: Avoid committing binary files (e.g., *.class, *.jar, *.exe) or third-party library files in to the repo.
❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact cs2103@comp.nus.edu.sg if you want to follow up on this post.
@KristopherPTaslim We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
No easy-to-detect issues 👍
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/duke/Duke.javalines38-115:Example from
src/main/java/duke/Parser.javalines26-126:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
Example from
src/main/java/duke/Duke.javalines117-122:Example from
src/main/java/duke/Duke.javalines131-135:Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Message (Subject Only)
No easy-to-detect issues 👍
Aspect: Binary files in repo
src\out\production\main\duke\Deadline.classsrc\out\production\main\duke\Duke.classsrc\out\production\main\duke\DukeException.classSuggestion: Avoid committing binary files (e.g.,
*.class,*.jar,*.exe) or third-party library files in to the repo.❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
cs2103@comp.nus.edu.sgif you want to follow up on this post.