This site is from a past semester! The current version will be here when the new semester starts.

Week 6 [Fri, Feb 10th] - Tutorial

1 Demo debugging in an IDE

Suggested pre-tutorial preparations:

  • Clone the https://github.com/nus-cs2113-AY2223S2/personbook repo to your Computer (no need to fork first).
  • Set it up in your IDE.
  • Use the IDE debugging to step through the code to understand how the code works. For example, you can try to find answers to these questions:
    • How to add a new find command to locate persons by name?
    • What's the purpose of the variable PersonBook#lastShownList? Is it really needed?

FYI, here's a relevant video used in the textbook


During the tutorial, demo your ability to do debugging using an IDE by performing the following tasks:

  1. Set a breakpoint in the following method of the Main class.
    /** Reads the user command and executes it, until the user issues the exit command.  */
    private void runCommandLoopUntilExitCommand() {
        Command command;
        do {
            String userCommandText = ui.getUserCommand();
            command = new Parser().parseCommand(userCommandText);
            CommandResult result = executeCommand(command);
            personBook.setLastShownList(result.getRelevantPersons());
            ui.showResultToUser(result);
    
        } while (!ExitCommand.isExit(command));
    }
    
  2. Use the debugger to step through the code while explaining how the code works. Start from the main method.
  3. Suppose the code behaves incorrectly when using the list command after adding two persons. Show how to set a conditional breakpoint so that execution pauses when the user types in the command list but doesn't pause for other commands.
    You need to set what is known as a conditional breakpoint.

2 Demo iP using the jar file

  • Copy your iP jar file to an empty folder.
  • Launch the jar file using the command prompt.
  • Input the commands specified by your tutor.
  • Take screenshots and paste them in the tutorial workspace document as instructed.

3 Receive feedback on the tP UG draft

  • The tutor will give feedback based on the UG draft that you uploaded to Canvas.
  • The feedback will be limited to the scope of v1.0 i.e., caution you if you seem to overambitious in you v1.0 plan.