CSCI 2134 - Software Development - Assignment No.3


  • 作业标题:CSCI 2134 - Software Development - Assignment No.3
  • 课程名称:Dalhouse University CSCI 2134 Software Development
  • 完成周期:1天

Objective

In this lab, you will work on your own or with another student to improve the robustness of
existing code using exceptions and assertions.

Preparation

  1. Ensure that you have your Integrated Development Editor (IDE) installed.
  2. Ensure that you are able to write and run a JUnit test case in the IDE. You will not have the
    time to both debug your IDE environment and complete the lab task within the lab time.
    The lab time should be able to concentrate on the lab task.
  3. Clone the Lab 6 repo: https://git.cs.dal.ca/courses/2021-fall/csci-2134/lab6/????.git
    where ???? is your CSID.
  4. Review the provided code listed in the Resources section below by reading the code of the
    class you will be fortifying (Matrix.java) and the unit tests (MatrixTest.java).
    These files are located in the src and test directories of the cloned project.
  5. You may also wish to read the provided primer on matrix operations, found in the docs
    directory.

Resources

  • Primer on matrices and example assertion_list.txt in the docs directory of the
    Lab 6 repository.
  • Code base to be debugged is in the src directory of the Lab 6 repository.
  • Test code is in the test directory of the Lab 6 repository.

Procedure

Set-up

  1. Open the project you created in preparation for this lab

Part 1: Add Exceptions to Matrix.java

  1. Review the code for getElem() and the constructors in Matrix.java as an example of
    what you are being asked to do.

  2. For each of following methods review the updated specifications in Matrix.java.
    Instead of returning null, the method should be modified to throw an exception.
    Implement this change in the following methods:

    • add()
    • multiplyWithScalar()
    • multiplyWithMatrix()
    • setElem()
  3. Run the regression tests (MatrixTest.java) to ensure that no tests have failed.

  4. Commit and push back to the repository.

Part 2: Add Tests to MatrixTest.java

  1. Review the code for getElemIndexOutOfBounds() in MatrixTest.java as an
    example of what you are being asked to do.
  2. For each of the methods that you modified in Matrix.java, add a test method to
    MatrixTest.java (named using the same pattern as for getElem(). These methods should
    test that the exceptions are being properly thrown.
  3. Commit and push the fix back to the repository.

Part 3: Assertions

  1. Review the methods in Matrix.java. Determine three (3) places in the code where an assert
    statement would be helpful. See the write() method in Matrix.java for an example.
    Note: placing the same assertion in multiple methods still only counts as one assertion. J
  2. Note the suggested locations in the file docs/assertion_list.txt. Include the
    method, the line number, and assertion condition
  3. Add the assertion to the code
  4. Commit and push the fix back to the repository.

Grading

The lab will be marked out of 4 points:

。。。


文章作者: IT神助攻
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 IT神助攻 !
  目录