@ananya21 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
Example from src/main/java/charlie/ui/Charlie.java
lines 26-26
:
private boolean priorityCommand = false;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
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/charlie/ui/Charlie.java
lines 43-107
:
public void start(Stage stage) {
initDuke("./data/charlie.txt");
// Step 1. Setting up required components
ScrollPane scrollPane = new ScrollPane();
VBox dialogContainer = new VBox();
scrollPane.setContent(dialogContainer);
TextField userInput = new TextField();
Button sendButton = new Button("Send");
AnchorPane mainLayout = new AnchorPane();
mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);
Scene scene = new Scene(mainLayout);
stage.setScene(scene);
stage.show();
stage.setTitle("charlie.ui.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);
//Step 3. Add functionality to handle user input.
sendButton.setOnMouseClicked((event) -> {
try {
handleUserInput(userInput, dialogContainer);
} catch (CharlieException e) {
System.out.println(e.getMessage());
}
});
userInput.setOnAction((event) -> {
try {
handleUserInput(userInput, dialogContainer);
} catch (CharlieException e) {
System.out.println(e.getMessage());
}
});
dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));
}
Example from src/main/java/charlie/ui/Charlie.java
lines 121-155
:
private void handleUserInput(TextField userInput, VBox dialogContainer) throws CharlieException {
String input = userInput.getText();
boolean isAddCommand = input.startsWith("todo") || input.startsWith("deadline")
|| input.startsWith("event");
if (isAddCommand) {
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, user),
DialogBox.getDukeDialog("Assign this task a priority: ", duke)
);
setPriority(true,input);
userInput.clear();
} else if (this.priorityCommand & this.priorityTaskCommand != null) {
if (isNumeric(input)) {
String fullPriorityCommand = this.priorityTaskCommand + " " + input;
String response = "Assigned the task this priority " + input;
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, user),
DialogBox.getDukeDialog(response, duke),
DialogBox.getDukeDialog(getResponse(fullPriorityCommand), duke)
);
userInput.clear();
setPriority(false, null);
} else {
throw new CharlieException("Priority should be a number");
}
} else {
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, user),
DialogBox.getDukeDialog(getResponse(input), duke)
);
userInput.clear();
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate 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/charlie/commands/Command.java
lines 11-17
:
/**
* Abstract execute method that aims to perform actions for a specific command.
* Needs to be overridden in sub-classes.
* @param taskList - task list loaded at the start of the program.
* @param storage - class responsible for adding and loading tasks from and into the file
* @throws CharlieException
*/
Example from src/main/java/charlie/storage/Storage.java
lines 55-62
:
/**
* The parseTaskFromFile method converts a single line of text into a specific Task object
* (to-Do, Deadline, or Event) based on the line's format, throwing an exception for unrecognized
* task types
* @param line line read from the storage file
* @return the task object
* @throws IllegalArgumentException
*/
Example from src/main/java/charlie/ui/Charlie.java
lines 108-113
:
/**
* 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.
*/
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
possible problems in commit a40f589
:
- Not in imperative mood (?)
possible problems in commit 28d3589
:
- Not in imperative mood (?)
possible problems in commit b2bcd07
:
Adding Charlie to ReadMe file
- Not in imperative mood (?)
Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
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 [email protected]
if you want to follow up on this post.