@WhasabiQ 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/Task.java lines 3-3:
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/Duke.java lines 8-54:
public static void main(String[] args) {
String logo = " _ _ _ _ _______________________________________ \n"
+ " | | _ | | | | | __ | | __ | __ |___ ___|\n"
+ " | | | | | | |----| | |__| | ------| |__| | |__|/ | | \n"
+ " | |_| |_| | |----| | | | |------ | | | | |__|\\ ___| |___\n"
+ " |_________|_| |_|_| |_|________|_| |_|______|_________|\n";
printThis("Hello from\n" + logo , 0);
printThis("What can do for you?",0);
taskListing.add(new ToDos("buy detergent"));
taskListing.add(new ToDos("buy Shampoo"));
taskListing.add(new Event("Keith Birthday","04.10.2021"));
taskListing.add(new Deadline("pay bills","23.11.2021"));
Scanner in;
String line;
while(true){
in = new Scanner(System.in);
line = in.nextLine();
if(line.equalsIgnoreCase("bye")) {
printThis("Bye. Hope to see you again soon!",0);
break;
}else if(line.equalsIgnoreCase("list")){
printList();
}else{
try{
addDeleteMarkTask(line);
}catch (ToDosBodyException e){
printThis("OOPS!!! The description of a todo cannot be empty",3);
}catch (DeadlineBodyException e){
printThis("OOPS!!! The description of a Deadline cannot be empty",3);
}catch (DeadlineByException e){
printThis("OOPS!!! When is the Deadline ?",3);
}catch (EventBodyException e){
printThis("OOPS!!! The description of a Event cannot be empty",3);
}catch (EventAtException e){
printThis("OOPS!!! When is the Event ?",3);
}catch (InvalidCommandException e){
printThis("OOPS!!! Invalid command please enter. Please try again",3);
}catch (DeleteBodyException e){
printThis("OOPS!!! The description of a Delete cannot be empty",3);
}catch (NumberFormatException e){
printThis("OOPS!!! Please enter a valid number",3);
}catch (IndexOutOfBoundsException e){
printThis("OOPS!!! Please select between 1 to " + taskListing.size(),3);
}
}
}
}
Example from src/main/java/Duke.java lines 94-131:
public static void addDeleteMarkTask(String item)
throws ToDosBodyException, DeadlineBodyException,DeadlineByException,
EventAtException,EventBodyException,InvalidCommandException,DeleteBodyException {
String[] split_1 = item.split("\\s+");
String[] split_2;
boolean isAdded = false;
boolean isRemoved = false;
boolean isDone = false;
if(split_1[0].equalsIgnoreCase("Todo")){
if(split_1.length == 1) throw new ToDosBodyException();
taskListing.add(new ToDos(split_1[1]));
isAdded = true;
}else if(split_1[0].equalsIgnoreCase("Deadline")){
if(split_1.length == 1)throw new DeadlineBodyException();
split_2 = item.split("/");
if(split_2.length == 1) throw new DeadlineByException();
taskListing.add(new Deadline(split_1[1],split_2[1]));
}else if(split_1[0].equalsIgnoreCase("Event")){
if(split_1.length == 1) throw new EventBodyException();
split_2 = item.split("/");
if(split_2.length == 1) throw new EventAtException();
taskListing.add(new Event(split_1[1],split_2[1]));
}else if(split_1[0].equalsIgnoreCase("delete")){
if(split_1.length == 1) throw new DeleteBodyException();
removeTask(Integer.parseInt(split_1[1]));
isRemoved = true;
}else if(split_1[0].equalsIgnoreCase("done")){
markTask(item);
isDone = true;
}
if (!isAdded && !isRemoved && !isDone) throw new InvalidCommandException();
if(isAdded){
printThis("Got it. I've added this task: " , 1);
printThis(taskListing.get(taskListing.size()-1).toString(), 0);
printThis("Now you have "+ taskListing.size()+ " tasks in the list." , 2);
}
}
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
No easy-to-detect issues 👍
ℹ️ The bot account @nus-se-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact tic2002@comp.nus.edu.sg if you want to follow up on this post.
@WhasabiQ 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/Task.javalines3-3: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/Duke.javalines8-54:Example from
src/main/java/Duke.javalines94-131: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
No easy-to-detect issues 👍
ℹ️ The bot account @nus-se-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
tic2002@comp.nus.edu.sgif you want to follow up on this post.