Giter Club home page Giter Club logo

ip's Introduction

Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot Duke. Given below are instructions on how to use it.

Setting up in Intellij

Prerequisites: JDK 11, update Intellij to the most recent version.

  1. Open Intellij (if you are not in the welcome screen, click File > Close Project to close the existing project first)
  2. Open the project into Intellij as follows:
    1. Click Open.
    2. Select the project directory, and click OK.
    3. If there are any further prompts, accept the defaults.
  3. Configure the project to use JDK 11 (not other versions) as explained in here.
    In the same dialog, set the Project language level field to the SDK default option.
  4. After that, locate the src/main/java/Duke.java file, right-click it, and choose Run Duke.main() (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
    Hello from
     ____        _        
    |  _ \ _   _| | _____ 
    | | | | | | | |/ / _ \
    | |_| | |_| |   <  __/
    |____/ \__,_|_|\_\___|
    

ip's People

Contributors

imrajsinghsandhu avatar j-lum avatar damithc avatar jiachen247 avatar

ip's Issues

Sharing iP code quality feedback [for @imrajsinghsandhu] - Round 2

@imrajsinghsandhu 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

Example from src/main/java/duke/main/Duke.java lines 45-45:

        // return "Duke heard: " + input;

Example from src/main/java/duke/main/Duke.java lines 64-64:

    // public void start(Stage primaryStage) throws Exception {

Example from src/main/java/duke/main/Duke.java lines 68-68:

    // ui = new Ui();

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

No easy-to-detect issues ๐Ÿ‘

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/duke/commands/Todo.java lines 16-23:

    /**
     * Handle the todo command.
     * 
     * @param command
     * @param tasks
     * @param input
     * @return res
     */

Example from src/main/java/duke/storage/Storage.java lines 37-43:

    /**
     * By loading i believe this should return a valid ArrayList - either empty or
     * prefilled with the duke.txt file.
     * 
     * @throws FileNotFoundException, DukeException cos thats whats declared in
     *                                Duke.java code.
     */

Example from src/main/java/duke/storage/Storage.java lines 107-112:

    /**
     * Method to write to the duke.txt file.
     * 
     * @param filePath path of the file to write to
     * @param addText  text we want to add to the file
     */

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)

possible problems in commit 92364cf:

Finalised changes to Duke

  • Not in imperative mood (?)

Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).

Aspect: Binary files in repo

No easy-to-detect issues ๐Ÿ‘

โ— 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.

Sharing iP code quality feedback [for @imrajsinghsandhu]

@imrajsinghsandhu We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.

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

Example from src/main/java/Duke.java lines 90-90:

        // Task[] list = new Task[100];

Example from src/main/java/Duke.java lines 159-159:

                // Task currTask = list[number];

Example from src/main/java/Duke.java lines 170-170:

                // Task currTask = list[number];

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/Duke.java lines 87-254:

    public static void main(String[] args) throws IOException, DukeException {

        // an array of tasks
        // Task[] list = new Task[100];
        int counter = 0;
        System.out.println(GREETING);
        // new Data Structure to hold the tasks
        ArrayList<Task> tasks = new ArrayList<Task>();

        // takes in the incoming prompt
        Scanner sc = new Scanner(System.in);

        // checks for the existence of data directory
        // and the duke.txt file
        File completeDirectory = new File("data/duke.txt");
        File dataFolder = new File("data");
        String dataPath = "data/duke.txt";

        // Check if the data directory exists.
        // Then create duke.txt if it doesnt.
        // if the folder and file exits, then we read the messages in there,
        // and update our tasks ArrayList.

        if (!completeDirectory.exists()) {
            if (!dataFolder.exists()) {
                // neither the full path nor the Folder exits
                // proceed to create the dataFolder first
                dataFolder.mkdir();
            }
            // here we will create the duke.txt file
            completeDirectory.createNewFile();
        } else {
            System.out.println("duke.txt already exists");
            // add the elements in the file to the tasks here

            // replacing the ArrayList Tasks
            tasks = ParseDukeTxt.readFile(completeDirectory);
        }

        // Outputs
        while (true) {

            String input = sc.nextLine();

            // we will check from 0 to the first space
            // this will let us know of the command
            String[] command = input.split(" ");

            if (input.equals("bye")) {
                // update the duke.txt file
                ParseDukeTxt.updateDukeTxt(dataPath, tasks);
                System.out.println(BYE);
                break;
            } else if (input.equals("list")) {

                System.out.println(LINE_BREAK);
                System.out.println("  " + LINE_INTRO);
                int internalCounter = 1;

                // iterate through the list
                for (Task task : tasks) {
                    if (task != null) {
                        System.out.println(" " + internalCounter + ". " + task);
                        ++internalCounter;
                    } else {
                        break;
                    }
                }
            } else if (command[0].equals("mark")) {

                int number = Integer.parseInt(command[1]) - 1;

                // Task currTask = list[number];
                Task currTask = tasks.get(number);
                boolean currState = currTask.getIsDone();
                currTask.setDone(!currState);

                System.out.println(LINE_BREAK);
                System.out.println("   " + MARK_MESSAGE);
                System.out.println("        [X] " + currTask.getDescription());
            } else if (command[0].equals("unmark")) {
                int number = Integer.parseInt(command[1]) - 1;

                // Task currTask = list[number];
                Task currTask = tasks.get(number);
                boolean currState = currTask.getIsDone();
                currTask.setDone(!currState);

                System.out.println(LINE_BREAK);
                System.out.println("   " + UNMARK_MESSAGE);
                System.out.println("        [ ] " + currTask.getDescription());
            } else if (command[0].equals("deadline")) {
                // deadline make some cups /by the day after
                if (command.length == 1) {
                    DukeException e = new DukeException("bro why la");
                    System.err.println(e.getMessage());
                } else {
                    String[] deadlineInput = input.split("/by");
                    String deadline = deadlineInput[1];
                    String left = deadlineInput[0];
                    String description = left.substring(9, left.length() - 1);
                    // create a new deadline
                    Task newTask = new Deadlines(description, deadline);
                    // adding to the array
                    // list[counter] = newTask;
                    tasks.add(newTask);
                    ++counter;
                    System.out.println(LINE_BREAK);
                    System.out
                            .println("Got it. I added this deadline already bro: \n" + " " + newTask.toString() + "\n");
                    System.out.println("Now you have " + counter + " tasks in the list. \n");
                }
            } else if (command[0].equals("event")) {

                // event project meeting /at Mon 2-4pm
                if (command.length == 1) {
                    DukeException e = new DukeException("OOPS!!! The description of an event cannot be empty.");
                    System.out.println(LINE_BREAK);
                    System.out.println(e.getMessage());
                } else {
                    String[] deadlineInput = input.split("/at");
                    String deadline = deadlineInput[1];
                    String left = deadlineInput[0];
                    String description = left.substring(6, left.length() - 1);
                    // create a new deadline
                    Task newTask = new Events(description, deadline);
                    // adding to the array
                    // list[counter] = newTask;
                    tasks.add(newTask);
                    ++counter;
                    System.out.println(LINE_BREAK);
                    System.out.println("Got it. I added this event already bro: \n" + " " + newTask.toString() + "\n");
                    System.out.println("Now you have " + counter + " tasks in the list. \n");
                }
            } else if (command[0].equals("todo")) {
                // here we declare the new task to be added (TODO)

                if (command.length == 1) {
                    DukeException e = new DukeException("โ˜น OOPS!!! The description of a todo cannot be empty.");
                    System.out.println(LINE_BREAK);
                    System.out.println(e.getMessage());
                } else {

                    Task t = new ToDos(input);

                    // list[counter] = t;
                    tasks.add(t);
                    System.out.println(LINE_BREAK);
                    System.out.println(" ok added alr bro: " + input);
                    ++counter;
                }
            } else if (command[0].equals("delete")) {
                // deleting a task
                // find the index to be deleted
                int number = Integer.parseInt(command[1]) - 1;
                // task being deleted
                Task beingDeleted = tasks.get(number);
                // deleting operation
                tasks.remove(number);
                System.out.println("Noted. I've removed this task: ");
                System.out.println("  " + beingDeleted);
                System.out.println("Now you have " + tasks.size() + " in the list.");
            } else {
                DukeException e = new DukeException("Tak faham banggg, speak in my language la bayi....");
                System.out.println(e.getMessage());
            }
        }
    }

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/Deadlines.java lines 13-15:

    /**
     * Deadline will take in a description and a by timeline.
     */

Example from src/main/java/Duke.java lines 30-35:

    /**
     * Method to write to the duke.txt file.
     * 
     * @param filePath path of the file to write to
     * @param addText  text we want to add to the file
     */

Example from src/main/java/Duke.java lines 42-47:

    /**
     * Method to append to the end of the present file.
     * 
     * @param filePath path of the file to write to
     * @param addText  text we want to add to the file
     */

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.

โ„น๏ธ 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 [email protected] if you want to follow up on this post.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.