Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 2.75 KB

DeveloperGuide.adoc

File metadata and controls

73 lines (54 loc) · 2.75 KB

AddressBook Level 1 - Developer Guide

Setting up

Prerequisites

  • JDK 9 or later

  • IntelliJ IDE

Importing the project into IntelliJ

  1. Open IntelliJ (if you are not in the welcome screen, click File > Close Project to close the existing project dialog first)

  2. Set up the correct JDK version

    1. Click Configure > Project Defaults > Project Structure

    2. If JDK 9 is listed in the drop down, select it. If it is not, click New…​ and select the directory where you installed JDK 9

    3. Click OK

  3. Click Import Project

  4. Locate the project directory and click OK

  5. Select Create project from existing sources and click Next

  6. Rename the project if you want. Click Next

  7. Ensure that your src folder is checked. Keep clicking Next

  8. Click Finish

Design

AddressBook saves data in a plain text file, one line for each person, in the format NAME p/PHONE e/EMAIL. Here is an example:

John Doe p/98765432 e/[email protected]
Jane Doe p/12346758 e/[email protected]

All person data are loaded to memory at start up and written to the file after any command that mutates data. In-memory data are held in a ArrayList<String[]> where each String[] object represents a person.

Testing

Windows

  1. Open a DOS window in the test folder

  2. Run the runtests.bat script

  3. If the script reports that there is no difference between actual.txt and expected.txt, the test has passed

Mac/Unix/Linux

  1. Open a terminal window in the test folder

  2. Run the runtests.sh script

  3. If the script reports that there is no difference between actual.txt and expected.txt, the test has passed

Troubleshooting

  • Problem: How do I examine the exact differences between actual.txt and expected.txt?
    Solution: You can use a diff/merge tool with a GUI e.g. WinMerge (on Windows).

  • Problem: The two files look exactly the same, but the test script reports they are different.
    Solution: This can happen because the line endings used by Windows is different from Unix-based OSes. Convert the actual.txt to the format used by your OS using some utility.

  • Problem: Test fails during the very first time.
    Solution: The output of the very first test run could be slightly different because the program creates a new storage file. Tests should pass from the 2nd run onwards.

  • Problem: AddressBook cannot be run, and src/ is treated as a normal folder instead of as a Sources Root.
    Solution: This can happen if you’ve accidentally imported the project as a Gradle project. First, disable "Use auto-import" in Settings (Preferences) > Build…​ > Build Tools > Gradle. Finally, right click on src/ > Mark Directory as > Sources Root.