Learning Outcomes

After studying this code and completing the corresponding exercises, you should be able to,

  1. Use High-Level Designs [LO-HighLevelDesign]
  2. Use Event-Driven Programming [LO-EventDriven]
  3. Use API Design [LO-ApiDesign]
  4. Use Assertions [LO-Assertions]
  5. Use Logging [LO-Logging]
  6. Use Defensive Coding [LO-DefensiveCoding]
  7. Use Build Automation [LO-BuildAutomation]
  8. Use Continuous Integration [LO-ContinuousIntegration]
  9. Use Code Coverage [LO-CodeCoverage]
  10. Apply Test Case Design Heuristics [LO-TestCaseDesignHeuristics]
  11. Write Integration Tests [LO-IntegrationTests]
  12. Perform System Testing [LO-SystemTesting]
  13. Automate GUI Testing [LO-AutomateGuiTesting]
  14. Apply Design Patterns [LO-DesignPatterns]
  15. Use Static Analysis [LO-StaticAnalysis]
  16. Do Code Reviews [LO-CodeReview]

Use High-Level Designs [LO-HighLevelDesign]

Note how the Developer Guide describes the high-level design using an Architecture Diagrams and high-level sequence diagrams.


Use Event-Driven Programming [LO-EventDriven]

Note how the Developer Guide uses events to communicate with components without needing a direct coupling. Also note how the EventsCenter class acts as an event dispatcher to facilitate communication between event creators and event consumers.


Use API Design [LO-ApiDesign]

Note how components of AddressBook have well-defined APIs. For example, the API of the Logic component is given in the Logic.java

Resources


Use Assertions [LO-Assertions]

Note how the AddressBook app uses Java asserts to verify assumptions.

Resources

Exercise: Add more assertions


Use Logging [LO-Logging]

Note how the AddressBook app uses Java’s java.util.log package to do logging.

Resources

Exercise: Add more logging

Add more logging to AddressBook as you see fit.


Use Defensive Coding [LO-DefensiveCoding]

Note how AddressBook uses the ReadOnly* interfaces to prevent objects being modified by clients who are not supposed to modify them.

Exercise: identify more places for defensive coding

Analyze the AddressBook code/design to identify,


Use Build Automation [LO-BuildAutomation]

Note how the AddressBook app uses Gradle to automate build tasks.

Resources

Exercise: Use gradle to run tasks

Exercise: Use gradle to manage dependencies


Use Continuous Integration [LO-ContinuousIntegration]

Note how the AddressBook app uses Travis to perform Continuous Integration. (Build Status)

Resources

Exercise: Use Travis in your own project


Use Code Coverage [LO-CodeCoverage]

Note how our CI server Travis uses Coveralls to report code coverage. (Coverage Status) After setting up Coveralls for your project, you can visit Coveralls website to find details about the coverage of code pushed to your repo. Here is an example.

Exercise: Use EclEmma to measure coverage locally


Apply Test Case Design Heuristics [LO-TestCaseDesignHeuristics]

The StringUtilTest.java class gives some examples of how to use Equivalence Partitions, Boundary Value Analysis, and Test Input Combination Heuristics to improve the efficiency and effectiveness of test cases testing the StringUtil.java class.

Exercise: Apply Test Case Design Heuristics to other places


Write Integration Tests [LO-IntegrationTests]

Consider the StorageManagerTest.java class.

Compare the above with LogicManagerTest. Many of the tests in that class (e.g. execute_add_* methods) tests are neither integration nor unit tests. They are a integration + unit tests because they not only checks if the LogicManager is correctly wired to its dependencies, but also checks the working of its dependencies. For example, the following two lines test the the LogicManager but also the Parser.

@Test
public void execute_add_invalidArgsFormat() throws Exception {
    ...
    assertCommandBehavior("add Valid Name 12345 e/valid@email.butNoPhonePrefix a/valid, address", expectedMessage);
    assertCommandBehavior("add Valid Name p/12345 valid@email.butNoPrefix a/valid, address", expectedMessage);
    ...
}

Exercise: Write unit and integration tests for the same method.


Perform System Testing [LO-SystemTesting]

Note how tests below src/test/java/guitests package (e.g AddCommandTest.java) are system tests because they test the entire system end-to-end.

Exercise: Write more system tests


Automate GUI Testing [LO-AutomateGuiTesting]

Note how this project uses TextFX library to automate GUI testing, including headless GUI testing.

Exercise: Write more automated GUI tests


Apply Design Patterns [LO-DesignPatterns]

Here are some example design patterns used in the code base.

Exercise: Discover other possible applications of the patterns

Exercise: Find more applicable patterns


Use Static Analysis [LO-StaticAnalysis]

Note how this project uses the CheckStyle static analysis tool to confirm compliance with the coding standard.

Other popular Java static analysis tools:

Exercise: Use the CheckStyle Eclipse plugin


Do Code Reviews [LO-CodeReview]

Here are some things you can comment on when reviewing code:

Resources

Exercise: Review a PR