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

[Kea Harvan Suyanto] iP #459

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

Conversation

kea-S
Copy link

@kea-S kea-S commented Feb 5, 2025

No description provided.

damithc and others added 30 commits July 11, 2024 16:52
In build.gradle, the dependencies on distZip and/or distTar causes
the shadowJar task to generate a second JAR file for which the
mainClass.set("seedu.duke.Duke") does not take effect.
Hence, this additional JAR file cannot be run.
For this product, there is no need to generate a second JAR file
to begin with.

Let's remove this dependency from the build.gradle to prevent the
shadowJar task from generating the extra JAR file.
Add save feature from branch-level-7
Add minimal date and time functionality from branch-level-8
Add storage class
Add automated UI testing
Copy link

@SomneelSaha2004 SomneelSaha2004 left a comment

Choose a reason for hiding this comment

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

LGTM!
A few small issues here and there but otw seems g!

Choose a reason for hiding this comment

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

You should add .class files to your gitignore, otw there is uneccessary bloat.

Choose a reason for hiding this comment

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

As compared to 1 Commands class, we can try to extract the functionality out into multiple classes.

Choose a reason for hiding this comment

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

when parsing the date the code should be put in a try catch block to make sure we handle incorrect input

Choose a reason for hiding this comment

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

try catch block should be used

Copy link

@bkkuan bkkuan left a comment

Choose a reason for hiding this comment

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

Code is well structured. Variables and method names follow Java conventions. Well done!

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Interaction {
TaskList list;
Copy link

Choose a reason for hiding this comment

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

Fields should generally be set to private for encapsulation


public Interaction() {
this.list = new TaskList();

// load or initialise data directory
Path dataDirectoryPath = Paths.get("../data");
Copy link

Choose a reason for hiding this comment

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

Its better to define constants for better maintainability
eg. private static final String DATA_DIRECTORY = "../data";
Then , Path dataDirectoryPath = Paths.get(DATA_DIRECTORY);

Scanner userInputScanner = new Scanner(System.in);
boolean saidBye = false;
while (!saidBye) {
String currUserInputText = userInputScanner.nextLine();
saidBye = Commands.executeCommand(currUserInputText, this.list, this.filePath, true);
Copy link

Choose a reason for hiding this comment

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

executeCommand() is called twice which may cause unintended behaviour.

import java.util.Iterator;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Copy link

Choose a reason for hiding this comment

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

java.util.ArrayList is imported twice. Remove the duplicate


public void writeToFile(Path filePath) {
// overwrite previous taskList to be empty, no need to add anything to the file
try (FileWriter fileWriter = new FileWriter(filePath.toString(), false)) {
Copy link

Choose a reason for hiding this comment

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

this block is redundant
FileWriter is opened but not used, which is pointless

import java.util.Iterator;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

public class TaskList extends ArrayList<Task> {
Copy link

Choose a reason for hiding this comment

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

generally a bad practice as it violates encapsulation

kea-S added 24 commits February 8, 2025 21:04
Some code is not of quality. Mostly, SLAP. Shep.java is also not needed
anymore after moving over to GUI.

Refactor the code to improve code quality and remove Shep.java.

Code was refactored in order to adhere to SLAP. Several classes had
multiple layers of abstraction so method extraction had to be done.
Some methods depended on the logic of other functions. To ensure that
the logic is followed  so that it can be utilised correctly by the class
Assertations were added.

Add Assertations to methods that require other methods to follow their
logic properly. Apart fromthe Commands class assertations never replaced
if else statements.

This is because assertations shouldn't be used to control the program
flow.
Logic bug regarding asserts replacing if-else statements caused program
to not be able to add tasks.

Reverted assert statements back to if-else.

If else statements worked before hand.
Refactor code, remove Shep.java
Fix merge conflict

Several merge conflicts when trying to merge master with assertions
added.

Cleaned up.

Should be.
Add assertations to reinforce logic
Add CI functionality using gradle.yml file under dir ./github/workflows
On the addition of any type of Task into a TaskList, no duplicate checks
are made, allowing the chance for a duplicate task to be added into the
test list.

This is a redundant feature and duplicate Tasks shouldn't be allowed.

In order to fix this, a checkDuplicates was added in the TaskList
class as well as an equals method in Task.

Also updated TaskListTests and CommandsTest classes to account for newer
situations.
On the addition of any type of Task into a TaskList, no duplicate checks
are made, allowing the chance for a duplicate task to be added into the
test list.

This is a redundant feature and duplicate Tasks shouldn't be allowed.

In order to fix this, a checkDuplicates was added in the TaskList
class as well as an equals method in Task.

Also updated TaskListTests and CommandsTest classes to account for newer
situations.
Refactor Commands.java
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.

5 participants